Module: ActionController::HideActions::ClassMethods

Defined in:
actionpack/lib/action_controller/metal/hide_actions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) action_methods

Overrides AbstractController::Base#action_methods to remove any methods that are listed as hidden methods.



42
43
44
# File 'actionpack/lib/action_controller/metal/hide_actions.rb', line 42

def action_methods
  @action_methods ||= Set.new(super.reject { |name| hidden_actions.include?(name) })
end

- (Object) hide_action(*args)

Sets all of the actions passed in as hidden actions.

Parameters

  • args - A list of actions



26
27
28
# File 'actionpack/lib/action_controller/metal/hide_actions.rb', line 26

def hide_action(*args)
  self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s)).freeze
end

- (Object) inherited(klass)



30
31
32
33
# File 'actionpack/lib/action_controller/metal/hide_actions.rb', line 30

def inherited(klass)
  klass.class_eval { @visible_actions = {} }
  super
end

- (Boolean) visible_action?(action_name)



35
36
37
38
# File 'actionpack/lib/action_controller/metal/hide_actions.rb', line 35

def visible_action?(action_name)
  return @visible_actions[action_name] if @visible_actions.key?(action_name)
  @visible_actions[action_name] = !hidden_actions.include?(action_name)
end