Class: ActiveSupport::Callbacks::CallTemplate::InstanceExec2

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

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ InstanceExec2

Returns a new instance of InstanceExec2.


479
480
481
# File 'activesupport/lib/active_support/callbacks.rb', line 479

def initialize(block)
  @override_block = block
end

Instance Method Details

#expand(target, value, block) ⇒ Object

Raises:

  • (ArgumentError)

483
484
485
486
# File 'activesupport/lib/active_support/callbacks.rb', line 483

def expand(target, value, block)
  raise ArgumentError unless block
  [target, @override_block || block, :instance_exec, target, block]
end

#inverted_lambdaObject


495
496
497
498
499
500
# File 'activesupport/lib/active_support/callbacks.rb', line 495

def inverted_lambda
  lambda do |target, value, &block|
    raise ArgumentError unless block
    !target.instance_exec(target, block, &@override_block)
  end
end

#make_lambdaObject


488
489
490
491
492
493
# File 'activesupport/lib/active_support/callbacks.rb', line 488

def make_lambda
  lambda do |target, value, &block|
    raise ArgumentError unless block
    target.instance_exec(target, block, &@override_block)
  end
end