Class: RubyEventStore::SidekiqScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/sidekiq_scheduler.rb,
lib/ruby_event_store/sidekiq_scheduler/version.rb

Constant Summary collapse

VERSION =
"0.1.3"

Instance Method Summary collapse

Constructor Details

#initialize(serializer:) ⇒ SidekiqScheduler

Returns a new instance of SidekiqScheduler.



7
8
9
# File 'lib/ruby_event_store/sidekiq_scheduler.rb', line 7

def initialize(serializer:)
  @serializer = serializer
end

Instance Method Details

#call(klass, record) ⇒ Object



11
12
13
14
15
# File 'lib/ruby_event_store/sidekiq_scheduler.rb', line 11

def call(klass, record)
  klass.perform_async(
    record.serialize(serializer).to_h.transform_keys(&:to_s)
  )
end

#verify(subscriber) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ruby_event_store/sidekiq_scheduler.rb', line 17

def verify(subscriber)
  if Class === subscriber
    !!(subscriber < Sidekiq::Worker)
  else
    subscriber.instance_of?(Sidekiq::Worker::Setter)
  end
end