Method: ObjectProtocol::Execution#call

Defined in:
lib/object_protocol/execution.rb

#call(protocol) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/object_protocol/execution.rb', line 16

def call(protocol)
  begin
    $object_protocol_spying_enabled = false
    participants.each(&method(:start_spying_on_public_methods_on))
    # we guard inside the methods with a global so that we don't start spying
    # while we're still redefining all the public methods on the participant
    $object_protocol_spying_enabled = true
    protocol.instance_exec(&blk)
  ensure
    $object_protocol_spying_enabled = false
    participants.each(&method(:stop_spying_on_public_methods_on))
  end
end