Class: Caricature::Messenger

Inherits:
Object
  • Object
show all
Defined in:
lib/caricature/messenger.rb

Overview

A base class to encapsulate method invocation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expectations, instance = nil) ⇒ Messenger

creates a new instance of this messaging strategy



17
18
19
# File 'lib/caricature/messenger.rb', line 17

def initialize(expectations, instance=nil)
  @instance, @expectations = instance, expectations
end

Instance Attribute Details

#expectationsObject (readonly)

the expecations that have been set for the isolation



14
15
16
# File 'lib/caricature/messenger.rb', line 14

def expectations
  @expectations
end

#instanceObject (readonly)

the real instance of the isolated subject used to forward calls in partial mocks



11
12
13
# File 'lib/caricature/messenger.rb', line 11

def instance
  @instance
end

#recorderObject

contains the recorder for recording method calls



7
8
9
# File 'lib/caricature/messenger.rb', line 7

def recorder
  @recorder
end

Instance Method Details

#deliver(method_name, return_type, *args, &b) ⇒ Object

deliver the message to the receiving isolation



22
23
24
25
# File 'lib/caricature/messenger.rb', line 22

def deliver(method_name, return_type, *args, &b)
  
  internal_deliver(:instance, method_name, return_type, *args, &b)
end

#deliver_to_class(method_name, return_type, *args, &b) ⇒ Object

deliver the message to class of the receiving isolation



28
29
30
# File 'lib/caricature/messenger.rb', line 28

def deliver_to_class(method_name, return_type, *args, &b)
  internal_deliver(:class, method_name, return_type, *args, &b)
end