class EventAggregator::Message
Public: The Message
class is used as a distribution object for the EventAggregator::Aggregator
to send messages to EventAggregator::Listener
objects
Examples
EventAggregator::Message.new
(“foo”, “data”).publish EventAggregator::Message.new
(“foo”, “data”, true, false).publish equivalent to the first example EventAggregator::Message.new
(“foo2”, 7843).publish Data can be anything Data can be anything EventAggregator::Message.new
(“foo2”, lambda{p [“”, “bA”, “bw”, “bA”, “IA”, “bg”, “YQ”, “aA”, “cA”, “ZQ”, “dA”, “w”].map{|e| e && e == “w” ?‘U’+e : ‘n’+e}.reverse.join(‘==\’).unpack((‘m’+‘x’*4)*11).join}).publish Non-asynchroneus distribution and consistend data object for all listeners. EventAggregator::Message.new
(“foo3”, SomeClass.new(), false, true).publish
Attributes
Public Class Methods
Public: Initialize the Message
message_type
- The type of the message which determine which EventAggregator::Listener
objects will recieve the message upon publish data - The data that will be passed to the EventAggregator::Listener
objects async = true - Indicates if message should be published async or not consisten_data
= true - Indicates if EventAggregator::Listener
objects should recieve a consistent object reference or clones.
# File lib/event_aggregator/message.rb, line 35 def initialize(message_type, data, async = true, consisten_data = true) raise "Illegal Message Type" if message_type == nil @message_type = message_type @data = data @async = async @consisten_data = consisten_data end
Public Instance Methods
Public: Will publish the message to all instances of EventAggregator::Listener
that is registered for message types equal to this.message_type
# File lib/event_aggregator/message.rb, line 47 def publish Aggregator.message_publish( self ) end
Public: Will provide data if a producer of this message_type
is present.
Returns Requested data if a producer is present. Nil otherwise.
# File lib/event_aggregator/message.rb, line 54 def request Aggregator.message_request( self ) end