Class: RubyEventStore::Subscriptions
- Inherits:
-
Object
- Object
- RubyEventStore::Subscriptions
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
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, topics) ⇒ Object
13
14
15
|
# File 'lib/ruby_event_store/subscriptions.rb', line 13
def add_subscription(subscriber, topics)
local.add(subscriber, topics)
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, topics) ⇒ Object
21
22
23
|
# File 'lib/ruby_event_store/subscriptions.rb', line 21
def add_thread_subscription(subscriber, topics)
thread.local.add(subscriber, topics)
end
|
#all_for(topic) ⇒ Object
29
30
31
|
# File 'lib/ruby_event_store/subscriptions.rb', line 29
def all_for(topic)
[local, global, thread].map { |r| r.all_for(topic) }.reduce(&:+)
end
|