Sha256: bc6e6604cdfa6637927147368ff296897742f1faa8077ed959f9338c69d1dc62

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

require 'logger'
require 'active_support/time'

require 'tickwork/at'
require 'tickwork/event'
require 'tickwork/manager'

module Tickwork
  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)
      Tickwork.manager.configure(&block)
    end

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

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

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

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

    def run
      Tickwork.manager.run
    end

    def clear!
      Tickwork.manager.clear! unless Tickwork.manager.nil?
      Tickwork.manager = Manager.new
    end
  end

  extend Methods
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tickwork-0.9.2 lib/tickwork.rb
tickwork-0.9.1 lib/tickwork.rb
tickwork-0.9.0 lib/tickwork.rb
tickwork-0.1.0 lib/tickwork.rb
tickwork-0.0.1 lib/tickwork.rb