class Sidekiq::Scheduler

def self.load_schedule_job(name, config)

Loads a job schedule into the Rufus::Scheduler and stores it in @@scheduled_jobs
def self.load_schedule_job(name, config)
  # If rails_env is set in the config, enforce ENV['RAILS_ENV'] as
  # required for the jobs to be scheduled.  If rails_env is missing, the
  # job should be scheduled regardless of what ENV['RAILS_ENV'] is set
  # to.
  if config['rails_env'].nil? || self.rails_env_matches?(config)
    logger.info "Scheduling #{name} #{config}"
    interval_defined = false
    interval_types = %w{cron every at in interval}
    interval_types.each do |interval_type|
      config_interval_type = config[interval_type]
      if !config_interval_type.nil? && config_interval_type.length > 0
        args = self.optionizate_interval_value(config_interval_type)
        # We want rufus_scheduler to return a job object, not a job id
        opts = { :job => true }
        @@scheduled_jobs[name] = self.rufus_scheduler.send(interval_type, *args, opts) do |job, time|
          config.delete(interval_type)
          idempotent_job_enqueue(name, time, config)
        end
        interval_defined = true
        break
      end
    end
    unless interval_defined
      logger.info "no #{interval_types.join(' / ')} found for #{config['class']} (#{name}) - skipping"
    end
  end
end