Class: Sinatra::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/d13n/service/background_job/sinatra.rb

Class Method Summary collapse

Class Method Details

.background_job(opts = {}, &block) ⇒ Object



6
7
8
9
# File 'lib/d13n/service/background_job/sinatra.rb', line 6

def background_job(opts = {}, &block)
  @background_jobs ||= []
  @background_jobs << {opts: opts, blk: block}
end

.background_job_run!Object



11
12
13
14
15
16
# File 'lib/d13n/service/background_job/sinatra.rb', line 11

def background_job_run!
  return if @background_jobs.nil?
  @background_jobs.each do |j|
    j[:blk].call(j[:opts])
  end
end

.run!(*args, &block) ⇒ Object



18
19
20
21
# File 'lib/d13n/service/background_job/sinatra.rb', line 18

def run!(*args, &block)
  background_job_run!
  run_without_callback(*args, &block)
end

.run_without_callbackObject



4
# File 'lib/d13n/service/background_job/sinatra.rb', line 4

alias_method :run_without_callback, :run!