Module: EXEL::Job
- Defined in:
- lib/exel/job.rb
Overview
The Job
module provides the main interface for defining and running EXEL jobs
Defined Under Namespace
Classes: Parser
Class Method Summary collapse
-
.define(job_name, &block) ⇒ Object
Registers a new job.
-
.registry ⇒ Hash
A hash of all the defined jobs.
-
.run(dsl_code_or_name, context = {}) ⇒ Object
If given a symbol as the first parameter, it attempts to run a previously registered job using that name.
Class Method Details
.define(job_name, &block) ⇒ Object
Registers a new job
11 12 13 14 |
# File 'lib/exel/job.rb', line 11 def define(job_name, &block) raise "Job #{job_name.inspect} is already defined" unless registry[job_name].nil? registry[job_name] = block end |
.registry ⇒ Hash
Returns A hash of all the defined jobs.
17 18 19 |
# File 'lib/exel/job.rb', line 17 def registry @registry ||= {} end |
.run(dsl_code_or_name, context = {}) ⇒ Object
If given a symbol as the first parameter, it attempts to run a previously registered job using that name. Alternatively, a string of code can be passed to be parsed and run directly.
28 29 30 31 32 33 |
# File 'lib/exel/job.rb', line 28 def run(dsl_code_or_name, context = {}) context = EXEL::Context.new(context) if context.instance_of?(Hash) ast = parse(dsl_code_or_name) ast ? ast.start(context) : raise(%(Job "#{dsl_code_or_name}" not found)) context end |