Class: ActiveSupport::Callbacks::CallTemplate::MethodCall

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/callbacks.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ MethodCall

Returns a new instance of MethodCall.



339
340
341
# File 'lib/active_support/callbacks.rb', line 339

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.



356
357
358
# File 'lib/active_support/callbacks.rb', line 356

def expand(target, value, block)
  [target, block, @method_name]
end

#inverted_lambdaObject



366
367
368
369
370
# File 'lib/active_support/callbacks.rb', line 366

def inverted_lambda
  lambda do |target, value, &block|
    !target.send(@method_name, &block)
  end
end

#make_lambdaObject



360
361
362
363
364
# File 'lib/active_support/callbacks.rb', line 360

def make_lambda
  lambda do |target, value, &block|
    target.send(@method_name, &block)
  end
end