Class: ObjectProtocol::SentMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/object_protocol/sent_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender:, receiver:, name:) ⇒ SentMessage

Returns a new instance of SentMessage.



5
6
7
8
9
10
11
# File 'lib/object_protocol/sent_message.rb', line 5

def initialize(sender:, receiver:, name:)
  @sender   = sender
  @receiver = receiver
  @name     = name

  @arguments_passed = false
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



3
4
5
# File 'lib/object_protocol/sent_message.rb', line 3

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/object_protocol/sent_message.rb', line 3

def name
  @name
end

#receiverObject (readonly)

Returns the value of attribute receiver.



3
4
5
# File 'lib/object_protocol/sent_message.rb', line 3

def receiver
  @receiver
end

#senderObject (readonly)

Returns the value of attribute sender.



3
4
5
# File 'lib/object_protocol/sent_message.rb', line 3

def sender
  @sender
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/object_protocol/sent_message.rb', line 29

def ==(other)
  other.respond_to?(:sender) &&
    sender == other.sender &&
    other.respond_to?(:receiver) &&
    receiver == other.receiver &&
    other.respond_to?(:name) &&
    name == other.name &&
    other.respond_to?(:arguments) &&
    arguments == other.arguments
end

#arguments_passed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/object_protocol/sent_message.rb', line 13

def arguments_passed?
  !!@arguments_passed
end

#inspectObject



25
26
27
# File 'lib/object_protocol/sent_message.rb', line 25

def inspect
  "<#{self.class.name}[#{sender.class.name}, :#{name}, #{receiver.class.name}]>"
end

#with(arguments) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/object_protocol/sent_message.rb', line 17

def with(arguments)
  @arguments = arguments

  @arguments_passed = true

  self
end