Class: AcidicJob::Builder
- Inherits:
-
Object
- Object
- AcidicJob::Builder
- Defined in:
- lib/acidic_job/builder.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #define_workflow ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #step(method_name, transactional: false) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
7 8 9 |
# File 'lib/acidic_job/builder.rb', line 7 def initialize @steps = [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
5 6 7 |
# File 'lib/acidic_job/builder.rb', line 5 def steps @steps end |
Instance Method Details
#define_workflow ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/acidic_job/builder.rb', line 16 def define_workflow # [ { does: "step 1", transactional: true }, { does: "step 2", transactional: false }, ... ] @steps << { "does" => FINISHED_RECOVERY_POINT } {}.tap do |workflow| @steps.each_cons(2).map do |enter_step, exit_step| enter_name = enter_step["does"] workflow[enter_name] = enter_step.merge("then" => exit_step["does"]) end end # { "step 1": { does: "step 1", transactional: true, then: "step 2" }, ... } end |
#step(method_name, transactional: false) ⇒ Object
11 12 13 14 |
# File 'lib/acidic_job/builder.rb', line 11 def step(method_name, transactional: false) @steps << { "does" => method_name.to_s, "transactional" => transactional } @steps end |