Class: RubyEventStore::Subscriptions::ThreadGlobalSubscriptions
- Inherits:
-
Object
- Object
- RubyEventStore::Subscriptions::ThreadGlobalSubscriptions
- Defined in:
- lib/ruby_event_store/subscriptions.rb
Instance Method Summary collapse
- #add(subscription) ⇒ Object
- #all_for(_event_type) ⇒ Object
-
#initialize ⇒ ThreadGlobalSubscriptions
constructor
A new instance of ThreadGlobalSubscriptions.
Constructor Details
#initialize ⇒ ThreadGlobalSubscriptions
Returns a new instance of ThreadGlobalSubscriptions.
95 96 97 |
# File 'lib/ruby_event_store/subscriptions.rb', line 95 def initialize @subscriptions = Concurrent::ThreadLocalVar.new([]) end |
Instance Method Details
#add(subscription) ⇒ Object
99 100 101 102 |
# File 'lib/ruby_event_store/subscriptions.rb', line 99 def add(subscription) @subscriptions.value += [subscription] -> { @subscriptions.value -= [subscription] } end |
#all_for(_event_type) ⇒ Object
104 105 106 |
# File 'lib/ruby_event_store/subscriptions.rb', line 104 def all_for(_event_type) @subscriptions.value end |