class RubyEventStore::Subscriptions::ThreadLocalSubscriptions
Public Class Methods
new()
click to toggle source
# File lib/ruby_event_store/subscriptions.rb, line 80 def initialize @subscriptions = Concurrent::ThreadLocalVar.new { Hash.new { |hsh, key| hsh[key] = [] } } end
Public Instance Methods
add(subscription, event_types)
click to toggle source
# File lib/ruby_event_store/subscriptions.rb, line 84 def add(subscription, event_types) event_types.each { |type| @subscriptions.value[type] << subscription } -> { event_types.each { |type| @subscriptions.value.fetch(type).delete(subscription) } } end
all_for(event_type)
click to toggle source
# File lib/ruby_event_store/subscriptions.rb, line 89 def all_for(event_type) @subscriptions.value[event_type] end