Class: RubyEventStore::PubSub::Subscriptions::LocalSubscriptions
- Inherits:
-
Object
- Object
- RubyEventStore::PubSub::Subscriptions::LocalSubscriptions
- Defined in:
- lib/ruby_event_store/pub_sub/subscriptions.rb
Instance Method Summary collapse
- #add(subscription, event_types) ⇒ Object
- #all_for(event_type) ⇒ Object
-
#initialize ⇒ LocalSubscriptions
constructor
A new instance of LocalSubscriptions.
Constructor Details
#initialize ⇒ LocalSubscriptions
Returns a new instance of LocalSubscriptions.
48 49 50 |
# File 'lib/ruby_event_store/pub_sub/subscriptions.rb', line 48 def initialize @subscriptions = Hash.new {|hsh, key| hsh[key] = [] } end |
Instance Method Details
#add(subscription, event_types) ⇒ Object
52 53 54 55 |
# File 'lib/ruby_event_store/pub_sub/subscriptions.rb', line 52 def add(subscription, event_types) event_types.each{ |type| @subscriptions[type.to_s] << subscription } ->() {event_types.each{ |type| @subscriptions.fetch(type.to_s).delete(subscription) } } end |
#all_for(event_type) ⇒ Object
57 58 59 |
# File 'lib/ruby_event_store/pub_sub/subscriptions.rb', line 57 def all_for(event_type) @subscriptions[event_type] end |