Sha256: 66cb2442ac186defdbaa72c39c07bbde2b4cda3b9c827895256f1fe191789a6c
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'forwardable' class ObjectProtocol class SatisfiableMessageExpectation extend Forwardable delegate %i(sender receiver message arguments arguments_specified?) => :@message_expectation def initialize(protocol:, message_expectation:) @protocol = protocol @message_expectation = message_expectation @satisfied = false end def attempt_to_apply_sent_message(sent_message) return if satisfied? return false unless is_sent_message_applicable?(sent_message) @satisfied = true end def is_sent_message_applicable?(sent_message) return false unless protocol.participant_by_name(sender.name) == sent_message.sender return false unless protocol.participant_by_name(receiver.name) == sent_message.receiver return false unless message == sent_message.name if arguments_specified? return false unless arguments == sent_message.arguments end true end def satisfied? !!@satisfied end def unsatisfied? !satisfied? end private attr_reader :protocol end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
object_protocol-0.2.0 | lib/object_protocol/satisfiable_message_expectation.rb |