Class: EventStoreClient::Subscriptions

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

Instance Method Summary collapse

Instance Method Details

#create(subscriber, event_types) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/event_store_client/subscriptions.rb', line 5

def create(subscriber, event_types)
  event_types.each do |type|
    subscription = subscriptions[type.to_s] || Subscription.new(type: type, name: service)
    subscription.subscribers |= [subscriber]
    create_subscription(subscription) unless @subscriptions.key?(type.to_s)
    @subscriptions[type.to_s] = subscription
  end
end

#eachObject



14
15
16
17
18
# File 'lib/event_store_client/subscriptions.rb', line 14

def each
  subscriptions.values.each do |subscription|
    yield(subscription)
  end
end

#get_updates(subscription) ⇒ Object



20
21
22
# File 'lib/event_store_client/subscriptions.rb', line 20

def get_updates(subscription)
  connection.consume_feed(subscription.stream, subscription.name)
end