Class: Que::Scheduler::SchedulerJobArgs

Inherits:
Hashie::Dash
  • Object
show all
Defined in:
lib/que/scheduler/scheduler_job_args.rb

Class Method Summary collapse

Class Method Details

.build(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/que/scheduler/scheduler_job_args.rb', line 13

def self.build(options)
  now = Que::Scheduler::Db.now
  parsed =
    if options.nil?
      # First ever run, there is nothing to do but reschedule self to run on the next minute.
      {
        last_run_time: now,
        job_dictionary: [],
      }
    else
      options = options.symbolize_keys
      {
        last_run_time:
          Que::Scheduler::TimeZone.time_zone.parse(options.fetch(:last_run_time)),
        job_dictionary: options.fetch(:job_dictionary),
      }
    end
  SchedulerJobArgs.new(parsed.merge(as_time: now))
end