Class: Bogus::RecordingProxy

Inherits:
BasicObject
Extended by:
Takes
Defined in:
lib/bogus/contracts/recording_proxy.rb

Instance Method Summary collapse

Methods included from Takes

takes

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/bogus/contracts/recording_proxy.rb', line 5

def method_missing(name, *args, &block)
  returned_value = @instance.__send__(name, *args, &block)
  @interactions_repository.record(@fake_name, name, *args) { returned_value }
  returned_value
rescue => e
  @interactions_repository.record(@fake_name, name, *args) { ::Kernel.raise(e) }
  ::Kernel.raise
end

Instance Method Details

#==(other) ⇒ Object

apparently even BasicObject has an equality operator



15
16
17
# File 'lib/bogus/contracts/recording_proxy.rb', line 15

def ==(other)
  method_missing(:==, other)
end

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/bogus/contracts/recording_proxy.rb', line 19

def respond_to?(name)
  @instance.respond_to?(name)
end