lib/floe/workflow/choice_rule.rb in floe-0.11.3 vs lib/floe/workflow/choice_rule.rb in floe-0.12.0
- old
+ new
@@ -2,29 +2,34 @@
module Floe
class Workflow
class ChoiceRule
class << self
- def build(payload)
+ def build(workflow, name, payload)
if (sub_payloads = payload["Not"])
- Floe::Workflow::ChoiceRule::Not.new(payload, build_children([sub_payloads]))
+ name += ["Not"]
+ Floe::Workflow::ChoiceRule::Not.new(workflow, name, payload, build_children(workflow, name, [sub_payloads]))
elsif (sub_payloads = payload["And"])
- Floe::Workflow::ChoiceRule::And.new(payload, build_children(sub_payloads))
+ name += ["And"]
+ Floe::Workflow::ChoiceRule::And.new(workflow, name, payload, build_children(workflow, name, sub_payloads))
elsif (sub_payloads = payload["Or"])
- Floe::Workflow::ChoiceRule::Or.new(payload, build_children(sub_payloads))
+ name += ["Or"]
+ Floe::Workflow::ChoiceRule::Or.new(workflow, name, payload, build_children(workflow, name, sub_payloads))
else
- Floe::Workflow::ChoiceRule::Data.new(payload)
+ name += ["Data"]
+ Floe::Workflow::ChoiceRule::Data.new(workflow, name, payload)
end
end
- def build_children(sub_payloads)
- sub_payloads.map { |payload| build(payload) }
+ def build_children(workflow, name, sub_payloads)
+ sub_payloads.map.with_index { |payload, i| build(workflow, name + [i.to_s], payload) }
end
end
- attr_reader :next, :payload, :variable, :children
+ attr_reader :next, :payload, :variable, :children, :name
- def initialize(payload, children = nil)
+ def initialize(_workflow, name, payload, children = nil)
+ @name = name
@payload = payload
@children = children
@next = payload["Next"]
@variable = payload["Variable"]