Sha256: 340cd1ab0c224304558c3e7c68c187bb43ef000bc9639ff88c02571cef204210

Contents?: true

Size: 981 Bytes

Versions: 10

Compression:

Stored size: 981 Bytes

Contents

require 'logger'
require 'active_support/time'

require 'clockwork/at'
require 'clockwork/event'
require 'clockwork/manager'

module Clockwork
  class << self
    def included(klass)
      klass.send "include", Methods
      klass.extend Methods
    end

    def manager
      @manager ||= Manager.new
    end

    def manager=(manager)
      @manager = manager
    end
  end

  module Methods
    def configure(&block)
      Clockwork.manager.configure(&block)
    end

    def handler(&block)
      Clockwork.manager.handler(&block)
    end

    def error_handler(&block)
      Clockwork.manager.error_handler(&block)
    end

    def on(event, options={}, &block)
      Clockwork.manager.on(event, options, &block)
    end

    def every(period, job, options={}, &block)
      Clockwork.manager.every(period, job, options, &block)
    end

    def run
      Clockwork.manager.run
    end

    def clear!
      Clockwork.manager = Manager.new
    end
  end

  extend Methods
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
clockwork-2.0.4 lib/clockwork.rb
clockwork-2.0.2 lib/clockwork.rb
clockwork-2.0.1 lib/clockwork.rb
clockwork-1.3.1 lib/clockwork.rb
clockwork-1.3.0 lib/clockwork.rb
clockwork-1.2.1 lib/clockwork.rb
clockwork-2.0.0 lib/clockwork.rb
clockwork-1.2.0 lib/clockwork.rb
clockwork-1.1.0 lib/clockwork.rb
clockwork-1.0.2 lib/clockwork.rb