Sha256: 93095fc7205d34c2a63707d9b03d5974e29538a2d699e8d3e75083626ab31a9b

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "celluloid"
require "ice_cube"

require "active_job/cron/version"
require "active_job/cron/configuration"
require "active_job/cron/schedulable"
require "active_job/cron/trackable"
require "active_job/cron/loggable"
require "active_job/cron/clock"
require "active_job/cron/handler"

module ActiveJob
  module Cron
    extend Configurable
    extend Trackable
    extend Schedulable

    def self.included(klass)
      super

      klass.extend(ActiveJob::Cron::Schedulable)
      klass.extend(ActiveJob::Cron::Trackable)

      subclasses << klass
    end

    class << self
      def jobs
        subclasses(true).select do |job|
          job.method_defined?(:perform)
        end
      end

      def handler
        if handler = Supervisor.handler
          handler
        else
          run!
          Supervisor.handler
        end
      end

      def clock
        if clock = Supervisor.clock
          clock
        else
          run!
          Supervisor.clock
        end
      end

      def run!
        Supervisor.run!
      end
    end
  end
end

require "active_job/cron/supervisor"
require "active_job/cron/railtie"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_job-cron-0.1.0 lib/active_job/cron.rb