Module: NowAndLater

Defined in:
lib/now_and_later.rb,
lib/now_and_later/engine.rb,
lib/now_and_later/enqueue.rb

Defined Under Namespace

Modules: Enqueue, Runner Classes: Engine, Queue, Service

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.backendObject

Backend stores reference to backend class



6
# File 'lib/now_and_later.rb', line 6

def self.backend; @backend ||= find_backend; end

.find_backendObject

returns symbol for current backend, e.g. :delayed_job

Raises:

  • (LoadError)


9
10
11
12
13
# File 'lib/now_and_later.rb', line 9

def self.find_backend
  return :delayed_job if defined?(Delayed::Job)
  return :resque if defined?(Resque)
  raise LoadError, "NowAndLater::Queue requires delayed_job or resque gem"
end

.with_backend(namespace = nil) ⇒ Object

WithBackend all extensions take form Class::WithBackend, e.g. Enqueue::WithDelayedJob



17
18
19
20
# File 'lib/now_and_later.rb', line 17

def self.with_backend(namespace = nil)
  mixin = "With#{backend.to_s.camelcase}"
  namespace.nil? ? mixin : "NowAndLater::#{namespace}::#{mixin}".constantize
end