2009-03-12 19:19:13 +00:00
|
|
|
module ActionController
|
|
|
|
module HideActions
|
2009-05-12 00:07:05 +00:00
|
|
|
extend ActiveSupport::DependencyModule
|
|
|
|
|
2009-05-07 15:38:57 +00:00
|
|
|
included do
|
2009-04-07 21:57:18 +00:00
|
|
|
extlib_inheritable_accessor :hidden_actions
|
2009-05-07 15:38:57 +00:00
|
|
|
self.hidden_actions ||= Set.new
|
2009-03-12 19:19:13 +00:00
|
|
|
end
|
2009-05-07 15:38:57 +00:00
|
|
|
|
2009-03-12 19:19:13 +00:00
|
|
|
def action_methods() self.class.action_names end
|
|
|
|
def action_names() action_methods end
|
2009-03-18 01:04:22 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def respond_to_action?(action_name)
|
|
|
|
!hidden_actions.include?(action_name) && (super || respond_to?(:method_missing))
|
|
|
|
end
|
2009-03-12 19:19:13 +00:00
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
def hide_action(*args)
|
|
|
|
args.each do |arg|
|
|
|
|
self.hidden_actions << arg.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_methods
|
|
|
|
@action_names ||= Set.new(super.reject {|name| self.hidden_actions.include?(name.to_s)})
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.action_names() action_methods end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|