Class: Dynflow::Persistence
- Inherits:
-
Object
- Object
- Dynflow::Persistence
- Defined in:
- lib/dynflow/persistence.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #find_execution_plans(options) ⇒ Object
-
#initialize(world, persistence_adapter) ⇒ Persistence
constructor
A new instance of Persistence.
- #load_action(step) ⇒ Object
- #load_execution_plan(id) ⇒ Object
- #load_step(execution_plan_id, step_id, world) ⇒ Object
- #save_action(execution_plan_id, action) ⇒ Object
- #save_execution_plan(execution_plan) ⇒ Object
- #save_step(step) ⇒ Object
Constructor Details
#initialize(world, persistence_adapter) ⇒ Persistence
Returns a new instance of Persistence.
9 10 11 12 13 |
# File 'lib/dynflow/persistence.rb', line 9 def initialize(world, persistence_adapter) @world = world @adapter = persistence_adapter @adapter.register_world(world) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/dynflow/persistence.rb', line 7 def adapter @adapter end |
Instance Method Details
#find_execution_plans(options) ⇒ Object
26 27 28 29 30 |
# File 'lib/dynflow/persistence.rb', line 26 def find_execution_plans() adapter.find_execution_plans().map do |execution_plan_hash| ExecutionPlan.new_from_hash(execution_plan_hash, @world) end end |
#load_action(step) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/dynflow/persistence.rb', line 15 def load_action(step) attributes = adapter. load_action(step.execution_plan_id, step.action_id). update(step: step, phase: step.phase) return Action.from_hash(attributes, step.world) end |
#load_execution_plan(id) ⇒ Object
32 33 34 35 |
# File 'lib/dynflow/persistence.rb', line 32 def load_execution_plan(id) execution_plan_hash = adapter.load_execution_plan(id) ExecutionPlan.new_from_hash(execution_plan_hash, @world) end |
#load_step(execution_plan_id, step_id, world) ⇒ Object
41 42 43 44 |
# File 'lib/dynflow/persistence.rb', line 41 def load_step(execution_plan_id, step_id, world) step_hash = adapter.load_step(execution_plan_id, step_id) ExecutionPlan::Steps::Abstract.from_hash(step_hash, execution_plan_id, world) end |
#save_action(execution_plan_id, action) ⇒ Object
22 23 24 |
# File 'lib/dynflow/persistence.rb', line 22 def save_action(execution_plan_id, action) adapter.save_action(execution_plan_id, action.id, action.to_hash) end |
#save_execution_plan(execution_plan) ⇒ Object
37 38 39 |
# File 'lib/dynflow/persistence.rb', line 37 def save_execution_plan(execution_plan) adapter.save_execution_plan(execution_plan.id, execution_plan.to_hash) end |
#save_step(step) ⇒ Object
46 47 48 |
# File 'lib/dynflow/persistence.rb', line 46 def save_step(step) adapter.save_step(step.execution_plan_id, step.id, step.to_hash) end |