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

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

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ InstanceExec2

Returns a new instance of InstanceExec2.



441
442
443
# File 'lib/active_support/callbacks.rb', line 441

def initialize(block)
  @override_block = block
end

Instance Method Details

#expand(target, value, block) ⇒ Object

Raises:

  • (ArgumentError)


445
446
447
448
# File 'lib/active_support/callbacks.rb', line 445

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

#inverted_lambdaObject



457
458
459
460
461
462
# File 'lib/active_support/callbacks.rb', line 457

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

#make_lambdaObject



450
451
452
453
454
455
# File 'lib/active_support/callbacks.rb', line 450

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