Class: Haku::Delayable::Delayed

Inherits:
Object
  • Object
show all
Defined in:
lib/haku/delayable.rb

Instance Method Summary collapse

Constructor Details

#initialize(service, options = {}) ⇒ Delayed

Returns a new instance of Delayed.



19
20
21
22
23
24
25
# File 'lib/haku/delayable.rb', line 19

def initialize(service, options={})
  @service = service
  @options = options.reverse_merge(
    job: "::Haku::Delayable::Job",
    queue: Haku.job_queue
  )
end

Instance Method Details

#call(params = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/haku/delayable.rb', line 27

def call(params={})
  if job.present? && defined?(job)
    job.set(@options).perform_later(@service, params)
  else
    @service.call(params)
  end
end