Class: Resque::JobChain::Chain
- Inherits:
-
Object
- Object
- Resque::JobChain::Chain
- Defined in:
- lib/resque/job_chain/chain.rb
Instance Attribute Summary collapse
-
#default_strategy ⇒ Object
readonly
Returns the value of attribute default_strategy.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#initial_context ⇒ Object
readonly
Returns the value of attribute initial_context.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(id:, steps:, default_strategy: nil, initial_context: {}) ⇒ Chain
constructor
A new instance of Chain.
- #start! ⇒ Object
- #total_steps ⇒ Object
Constructor Details
#initialize(id:, steps:, default_strategy: nil, initial_context: {}) ⇒ Chain
Returns a new instance of Chain.
6 7 8 9 10 11 |
# File 'lib/resque/job_chain/chain.rb', line 6 def initialize(id:, steps:, default_strategy: nil, initial_context: {}) @id = id @steps = steps @default_strategy = default_strategy || JobChain.configuration.default_strategy @initial_context = initial_context end |
Instance Attribute Details
#default_strategy ⇒ Object (readonly)
Returns the value of attribute default_strategy.
4 5 6 |
# File 'lib/resque/job_chain/chain.rb', line 4 def default_strategy @default_strategy end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/resque/job_chain/chain.rb', line 4 def id @id end |
#initial_context ⇒ Object (readonly)
Returns the value of attribute initial_context.
4 5 6 |
# File 'lib/resque/job_chain/chain.rb', line 4 def initial_context @initial_context end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
4 5 6 |
# File 'lib/resque/job_chain/chain.rb', line 4 def steps @steps end |
Instance Method Details
#start! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/resque/job_chain/chain.rb', line 13 def start! started = Persistence.start_chain( chain_id: id, steps: steps, context: initial_context ) if started steps.first.enqueue(id, 0, initial_context) Observable.notify(:chain_started, id) end started end |
#total_steps ⇒ Object
28 29 30 |
# File 'lib/resque/job_chain/chain.rb', line 28 def total_steps steps.length end |