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

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/callbacks.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ MethodCall

Returns a new instance of MethodCall.



377
378
379
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/callbacks.rb', line 377

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.



394
395
396
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/callbacks.rb', line 394

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

#inverted_lambdaObject



404
405
406
407
408
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/callbacks.rb', line 404

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

#make_lambdaObject



398
399
400
401
402
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/callbacks.rb', line 398

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