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.


64
65
66
# File 'lib/ruby_event_store/subscriptions.rb', line 64

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

Instance Method Details

#add(subscription, event_types) ⇒ Object


68
69
70
71
# File 'lib/ruby_event_store/subscriptions.rb', line 68

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


73
74
75
# File 'lib/ruby_event_store/subscriptions.rb', line 73

def all_for(event_type)
  @subscriptions[event_type]
end