Class: RubyEventStore::Subscriptions::LocalSubscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/subscriptions.rb

Instance Method Summary collapse

Constructor Details

#initializeLocalSubscriptions

Returns a new instance of LocalSubscriptions.



50
51
52
# File 'lib/ruby_event_store/subscriptions.rb', line 50

def initialize
  @subscriptions = Hash.new { |hsh, key| hsh[key] = [] }
end

Instance Method Details

#add(subscription, event_types) ⇒ Object



54
55
56
57
# File 'lib/ruby_event_store/subscriptions.rb', line 54

def add(subscription, event_types)
  event_types.each { |type| @subscriptions[type] << subscription }
  -> { event_types.each { |type| @subscriptions.fetch(type).delete(subscription) } }
end

#all_for(event_type) ⇒ Object



59
60
61
# File 'lib/ruby_event_store/subscriptions.rb', line 59

def all_for(event_type)
  @subscriptions[event_type]
end