Module: GovernorBackground

Defined in:
lib/governor_background.rb,
lib/governor_background/rails.rb,
lib/governor_background/handler.rb,
lib/governor_background/resque/job.rb,
lib/governor_background/delayed/job.rb,
lib/governor_background/job_manager.rb,
lib/governor_background/resque/resource.rb,
lib/governor_background/resque/performer.rb,
lib/governor_background/delayed/performer.rb,
lib/governor_background/controllers/methods.rb,
lib/governor_background/resque/performer_with_state.rb

Defined Under Namespace

Modules: Controllers, Delayed, Resque Classes: Engine, Handler, JobManager

Constant Summary collapse

@@blocks =
{}

Class Method Summary collapse

Class Method Details

.register(job_name, &block) ⇒ Object

Registers this job to be run later. Must be called upon application initialization.

Example:

GovernorBackground.register('twitter_post') do |content|
  Twitter.update(content)
end

Job names must be globally unique. It’s recommended that you preface the job name with the name of the containing plugin.



30
31
32
# File 'lib/governor_background.rb', line 30

def self.register(job_name, &block)
  @@blocks[job_name.to_s] = block
end

.retrieve(job_name) ⇒ Object

Retrieves the block for a job_name, which must have been previously registered. This will return a Proc object if the job is found, or nil if no job was registered under this name.



48
49
50
# File 'lib/governor_background.rb', line 48

def self.retrieve(job_name)
  @@blocks[job_name.to_s]
end

.run(job_name, *arguments) ⇒ Object

Runs the job with the supplied arguments.

Example:

GovernorBackground.run('twitter_post', 'I am so awesome')

job_name refers to the identifier for a previously registered job.



41
42
43
# File 'lib/governor_background.rb', line 41

def self.run(job_name, *arguments)
  GovernorBackground::Handler.run_in_background job_name, *arguments
end