Module: ActionArgs::ActiveSupport::CallbackParameterizer

Included in:
ActiveSupport::Callbacks::CallTemplate
Defined in:
lib/action_args/callbacks.rb

Overview

For Rails >= 5.1

Instance Method Summary collapse

Instance Method Details

#expandObject

Extending AS::Callbacks::Callback’s ‘expand` not just to call specified method but to call the method with method parameters taken from `params`. This would happen only when

  • the target object is_a ActionController object

  • the filter was not defined via lambda



14
15
16
17
18
19
20
21
22
23
# File 'lib/action_args/callbacks.rb', line 14

def expand(*)
  target, block, method, *arguments = super

  if (ActionController::Base === target) && (method != :instance_exec) && arguments.empty?
    target.strengthen_params! method
    arguments = target.extract_method_arguments_from_params method
  end

  [target, block, method, *arguments]
end