Class: RubyEventStore::Subscriptions

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

Defined Under Namespace

Classes: GlobalSubscriptions, LocalSubscriptions, ThreadGlobalSubscriptions, ThreadLocalSubscriptions, ThreadSubscriptions

Instance Method Summary collapse

Constructor Details

#initializeSubscriptions

Returns a new instance of Subscriptions.



7
8
9
10
11
# File 'lib/ruby_event_store/subscriptions.rb', line 7

def initialize
  @local = LocalSubscriptions.new
  @global = GlobalSubscriptions.new
  @thread = ThreadSubscriptions.new
end

Instance Method Details

#add_global_subscription(subscriber) ⇒ Object



17
18
19
# File 'lib/ruby_event_store/subscriptions.rb', line 17

def add_global_subscription(subscriber)
  global.add(subscriber)
end

#add_subscription(subscriber, event_types) ⇒ Object



13
14
15
# File 'lib/ruby_event_store/subscriptions.rb', line 13

def add_subscription(subscriber, event_types)
  local.add(subscriber, event_types)
end

#add_thread_global_subscription(subscriber) ⇒ Object



25
26
27
# File 'lib/ruby_event_store/subscriptions.rb', line 25

def add_thread_global_subscription(subscriber)
  thread.global.add(subscriber)
end

#add_thread_subscription(subscriber, event_types) ⇒ Object



21
22
23
# File 'lib/ruby_event_store/subscriptions.rb', line 21

def add_thread_subscription(subscriber, event_types)
  thread.local.add(subscriber, event_types)
end

#all_for(event_type) ⇒ Object



29
30
31
# File 'lib/ruby_event_store/subscriptions.rb', line 29

def all_for(event_type)
  [local, global, thread].map { |r| r.all_for(event_type) }.reduce(&:+)
end