Class: RailsEventStore::ActiveJobScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_event_store/active_job_scheduler.rb

Instance Method Summary collapse

Constructor Details

#initialize(serializer:) ⇒ ActiveJobScheduler

Returns a new instance of ActiveJobScheduler.



7
8
9
# File 'lib/rails_event_store/active_job_scheduler.rb', line 7

def initialize(serializer:)
  @serializer = serializer
end

Instance Method Details

#call(klass, record) ⇒ Object



11
12
13
# File 'lib/rails_event_store/active_job_scheduler.rb', line 11

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

#verify(subscriber) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rails_event_store/active_job_scheduler.rb', line 15

def verify(subscriber)
  if Class === subscriber
    !!(subscriber < ActiveJob::Base)
  else
    subscriber.instance_of?(ActiveJob::ConfiguredJob)
  end
end