Sha256: 215d32b129c6f35b95688a8db20194deb3a2b81b332d5f728ded51061cccb447
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
module EventAggregator class Aggregator @@listeners = Hash.new([]) @@message_types = Hash.new def self.register( listener, message_type ) @@listeners[message_type] << listener unless @@listeners[message_type].include?(listener) end def self.unregister( listener, message_type ) @@listeners[message_type].delete listener end def self.message_publish ( message ) return "Not a valid message" unless message.is_a? EventAggregator::Message @@listeners[message.message_type].each do |l| l.recieve_message message end end def self.register_message_type(message_type) @@message_types[message_types] = [] unless @@message_types[message_types] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
event_aggregator-0.0.1 | lib/event_aggregator/aggregator.rb |