Class: ObjectProtocol::SatisfactionAttempt
- Inherits:
-
Object
- Object
- ObjectProtocol::SatisfactionAttempt
- Defined in:
- lib/object_protocol/satisfaction_attempt.rb
Instance Method Summary collapse
-
#initialize(protocol, &blk) ⇒ SatisfactionAttempt
constructor
A new instance of SatisfactionAttempt.
- #to_bool ⇒ Object
- #to_rspec_matcher_failure_message_lines ⇒ Object
Constructor Details
#initialize(protocol, &blk) ⇒ SatisfactionAttempt
Returns a new instance of SatisfactionAttempt.
6 7 8 9 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 6 def initialize(protocol, &blk) @protocol = protocol @blk = blk end |
Instance Method Details
#to_bool ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 11 def to_bool execution.call(protocol) unsatisfied_steps = protocol.steps.map do |step| SatisfiableStep.new(protocol: protocol, step: step) end execution..each do || next_step = unsatisfied_steps.first next_step.() if next_step.satisfied? unsatisfied_steps.shift end end unsatisfied_steps.empty? end |
#to_rspec_matcher_failure_message_lines ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/object_protocol/satisfaction_attempt.rb', line 31 def return ["<empty execution>"] if execution..empty? execution..map do || fragment_base = "#{protocol.name_of_participant(sent_message.sender)}"\ ".sent(:#{sent_message.name})"\ ".to(#{protocol.name_of_participant(sent_message.receiver)})" if .arguments_passed? "#{fragment_base}.with(#{sent_message.arguments})" else fragment_base end end end |