dynflow 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,9 +100,7 @@ module Dynflow
100
100
  @run_step_id = Type! attributes.fetch(:run_step_id), Integer, NilClass
101
101
  @finalize_step_id = Type! attributes.fetch(:finalize_step_id), Integer, NilClass
102
102
 
103
- @execution_plan = Type!(attributes.fetch(:execution_plan),
104
- ExecutionPlan) if phase? Plan, Present
105
- @trigger = Type! attributes.fetch(:trigger), Action, NilClass if phase? Plan
103
+ @execution_plan = Type!(attributes.fetch(:execution_plan), ExecutionPlan) if phase? Present
106
104
 
107
105
  getter =-> key, required do
108
106
  required ? attributes.fetch(key) : attributes.fetch(key, {})
@@ -142,6 +140,12 @@ module Dynflow
142
140
  end
143
141
  end
144
142
 
143
+ def set_plan_context(execution_plan, trigger)
144
+ phase! Plan
145
+ @execution_plan = Type! execution_plan, ExecutionPlan
146
+ @trigger = Type! trigger, Action, NilClass
147
+ end
148
+
145
149
  def trigger
146
150
  phase! Plan
147
151
  @trigger
@@ -143,7 +143,8 @@ module Dynflow
143
143
 
144
144
  def prepare(action_class)
145
145
  save
146
- @root_plan_step = add_step(Steps::PlanStep, action_class, generate_action_id)
146
+ @root_plan_step = add_plan_step(action_class)
147
+ @root_plan_step.save
147
148
  end
148
149
 
149
150
  def plan(*args)
@@ -225,8 +226,10 @@ module Dynflow
225
226
  current_run_flow.add_and_resolve(@dependency_graph, new_flow) if current_run_flow
226
227
  end
227
228
 
228
- def add_plan_step(action_class, planned_by)
229
- add_step(Steps::PlanStep, action_class, generate_action_id, planned_by.plan_step_id)
229
+ def add_plan_step(action_class, planned_by = nil)
230
+ add_step(Steps::PlanStep, action_class, generate_action_id, planned_by && planned_by.plan_step_id).tap do |step|
231
+ step.initialize_action
232
+ end
230
233
  end
231
234
 
232
235
  def add_run_step(action)
@@ -37,25 +37,17 @@ module Dynflow
37
37
 
38
38
  # @return [Action]
39
39
  def execute(execution_plan, trigger, *args)
40
+ unless @action
41
+ raise "The action was not initialized, you might forgot to call initialize_action method"
42
+ end
43
+ @action.set_plan_context(execution_plan, trigger)
40
44
  Type! execution_plan, ExecutionPlan
41
- attributes = { execution_plan_id: execution_plan.id,
42
- id: action_id,
43
- step: self,
44
- plan_step_id: self.id,
45
- run_step_id: nil,
46
- finalize_step_id: nil,
47
- phase: phase,
48
- execution_plan: execution_plan,
49
- trigger: trigger }
50
- action = action_class.new(attributes, execution_plan.world)
51
- persistence.save_action(execution_plan_id, action)
52
-
53
- with_meta_calculation(action) do
54
- action.execute(*args)
45
+ with_meta_calculation(@action) do
46
+ @action.execute(*args)
55
47
  end
56
48
 
57
- persistence.save_action(execution_plan_id, action)
58
- return action
49
+ persistence.save_action(execution_plan_id, @action)
50
+ return @action
59
51
  end
60
52
 
61
53
  def self.state_transitions
@@ -83,6 +75,19 @@ module Dynflow
83
75
  hash[:real_time],
84
76
  hash[:children]
85
77
  end
78
+
79
+ def initialize_action
80
+ attributes = { execution_plan_id: execution_plan_id,
81
+ id: action_id,
82
+ step: self,
83
+ plan_step_id: self.id,
84
+ run_step_id: nil,
85
+ finalize_step_id: nil,
86
+ phase: phase}
87
+ @action = action_class.new(attributes, world)
88
+ persistence.save_action(execution_plan_id, @action)
89
+ @action
90
+ end
86
91
  end
87
92
  end
88
93
  end
@@ -9,15 +9,15 @@ module Dynflow
9
9
  step = DummyStep.new
10
10
  action_class.new(
11
11
  { step: DummyStep.new,
12
- execution_plan: execution_plan,
13
- trigger: trigger,
14
12
  execution_plan_id: execution_plan.id,
15
13
  id: Testing.get_id,
16
14
  phase: Action::Plan,
17
15
  plan_step_id: step.id,
18
16
  run_step_id: nil,
19
17
  finalize_step_id: nil },
20
- execution_plan.world)
18
+ execution_plan.world).tap do |action|
19
+ action.set_plan_context(execution_plan, trigger)
20
+ end
21
21
  end
22
22
 
23
23
  def create_action_presentation(action_class)
@@ -1,3 +1,3 @@
1
1
  module Dynflow
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-13 00:00:00.000000000 Z
12
+ date: 2014-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport