Class: ObjectProtocol::SatisfiableMessageExpectation
- Inherits:
-
Object
- Object
- ObjectProtocol::SatisfiableMessageExpectation
- Extended by:
- Forwardable
- Defined in:
- lib/object_protocol/satisfiable_message_expectation.rb
Instance Method Summary collapse
- #attempt_to_apply_sent_message(sent_message) ⇒ Object
-
#initialize(protocol:, message_expectation:) ⇒ SatisfiableMessageExpectation
constructor
A new instance of SatisfiableMessageExpectation.
- #is_sent_message_applicable?(sent_message) ⇒ Boolean
- #satisfied? ⇒ Boolean
- #unsatisfied? ⇒ Boolean
Constructor Details
#initialize(protocol:, message_expectation:) ⇒ SatisfiableMessageExpectation
Returns a new instance of SatisfiableMessageExpectation.
9 10 11 12 13 14 |
# File 'lib/object_protocol/satisfiable_message_expectation.rb', line 9 def initialize(protocol:, message_expectation:) @protocol = protocol @message_expectation = @satisfied = false end |
Instance Method Details
#attempt_to_apply_sent_message(sent_message) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/object_protocol/satisfiable_message_expectation.rb', line 16 def () return if satisfied? return false unless () @satisfied = true end |
#is_sent_message_applicable?(sent_message) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/object_protocol/satisfiable_message_expectation.rb', line 23 def () return false unless protocol.participant_by_name(sender.name) == .sender return false unless protocol.participant_by_name(receiver.name) == .receiver return false unless == .name if arguments_specified? return false unless arguments == .arguments end true end |
#satisfied? ⇒ Boolean
35 36 37 |
# File 'lib/object_protocol/satisfiable_message_expectation.rb', line 35 def satisfied? !!@satisfied end |
#unsatisfied? ⇒ Boolean
39 40 41 |
# File 'lib/object_protocol/satisfiable_message_expectation.rb', line 39 def unsatisfied? !satisfied? end |