Module: Troles::Common::EventManager::ClassMethods
- Included in:
- Troles::Common::EventManager
- Defined in:
- lib/troles/common/event_manager.rb
Overview
TODO:
Instance Attribute Summary collapse
-
#subscribers ⇒ Object
Returns the value of attribute subscribers.
Instance Method Summary collapse
- #add_subscribers(subscribers) ⇒ Object
- #publish_change(event, options) ⇒ Object
- #remove_subscribers(subscribers) ⇒ Object
Instance Attribute Details
#subscribers ⇒ Object
Returns the value of attribute subscribers.
15 16 17 |
# File 'lib/troles/common/event_manager.rb', line 15 def subscribers @subscribers end |
Instance Method Details
#add_subscribers(subscribers) ⇒ Object
29 30 31 |
# File 'lib/troles/common/event_manager.rb', line 29 def add_subscribers subscribers self.subscribers << subscribers end |
#publish_change(event, options) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/troles/common/event_manager.rb', line 21 def publish_change event, # from = options[:from] subscribers.each do |subscriber| subscriber.notify(event) if subscriber.respond_to?(:notify) end true end |
#remove_subscribers(subscribers) ⇒ Object
33 34 35 |
# File 'lib/troles/common/event_manager.rb', line 33 def remove_subscribers subscribers self.subscribers - subscribers end |