Class: ActiveSupport::Callbacks::CallTemplate::MethodCall
- Defined in:
- lib/active_support/callbacks.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#expand(target, value, block) ⇒ Object
Return the parts needed to make this call, with the given input values.
-
#initialize(method) ⇒ MethodCall
constructor
A new instance of MethodCall.
- #inverted_lambda ⇒ Object
- #make_lambda ⇒ Object
Constructor Details
#initialize(method) ⇒ MethodCall
Returns a new instance of MethodCall.
380 381 382 |
# File 'lib/active_support/callbacks.rb', line 380 def initialize(method) @method_name = method end |
Instance Method Details
#expand(target, value, block) ⇒ Object
Return the parts needed to make this call, with the given input values.
Returns an array of the form:
[target, block, method, *arguments]
This array can be used as such:
target.send(method, *arguments, &block)
The actual invocation is left up to the caller to minimize call stack pollution.
397 398 399 |
# File 'lib/active_support/callbacks.rb', line 397 def (target, value, block) [target, block, @method_name] end |
#inverted_lambda ⇒ Object
407 408 409 410 411 |
# File 'lib/active_support/callbacks.rb', line 407 def inverted_lambda lambda do |target, value, &block| !target.send(@method_name, &block) end end |
#make_lambda ⇒ Object
401 402 403 404 405 |
# File 'lib/active_support/callbacks.rb', line 401 def make_lambda lambda do |target, value, &block| target.send(@method_name, &block) end end |