Module: ActionArgs::ClassMethods

Defined in:
lib/rails-action-args/abstract_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_arguments(action) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails-action-args/abstract_controller.rb', line 12

def action_arguments(action)
  @action_arguments ||= {}
  return @action_arguments[action] if @action_arguments[action]

  arguments = instance_method(action).get_args.first || []

  defaults = arguments.map do |arg|
    if arg.size == 2
      arg.first
    end
  end.compact
  @action_arguments[action] = [arguments, defaults]
end