W3cubDocs

/Ruby on Rails 7.0

class ActiveSupport::Callbacks::CallTemplate::MethodCall

Parent:
Object

Public Class Methods

new(method) Show source
# File activesupport/lib/active_support/callbacks.rb, line 377
def initialize(method)
  @method_name = method
end

Public Instance Methods

expand(target, value, block) Show source
# File activesupport/lib/active_support/callbacks.rb, line 394
def expand(target, value, block)
  [target, block, @method_name]
end

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.

inverted_lambda() Show source
# File activesupport/lib/active_support/callbacks.rb, line 404
def inverted_lambda
  lambda do |target, value, &block|
    !target.send(@method_name, &block)
  end
end
make_lambda() Show source
# File activesupport/lib/active_support/callbacks.rb, line 398
def make_lambda
  lambda do |target, value, &block|
    target.send(@method_name, &block)
  end
end

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.