Class: Floe::Workflow::ChoiceRule
- Inherits:
-
Object
- Object
- Floe::Workflow::ChoiceRule
- Includes:
- ValidationMixin
- Defined in:
- lib/floe/workflow/choice_rule.rb,
lib/floe/workflow/choice_rule/or.rb,
lib/floe/workflow/choice_rule/and.rb,
lib/floe/workflow/choice_rule/not.rb,
lib/floe/workflow/choice_rule/data.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(workflow, name, payload, children = nil) ⇒ ChoiceRule
constructor
A new instance of ChoiceRule.
- #true? ⇒ Boolean
Methods included from ValidationMixin
included, #invalid_field_error!, #missing_field_error!, #parser_error!, #runtime_field_error!, #workflow_state?, #wrap_parser_error
Constructor Details
#initialize(workflow, name, payload, children = nil) ⇒ ChoiceRule
Returns a new instance of ChoiceRule.
32 33 34 35 36 37 38 39 |
# File 'lib/floe/workflow/choice_rule.rb', line 32 def initialize(workflow, name, payload, children = nil) @name = name @payload = payload @children = children @next = payload["Next"] validate_next!(workflow) end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
30 31 32 |
# File 'lib/floe/workflow/choice_rule.rb', line 30 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/floe/workflow/choice_rule.rb', line 30 def name @name end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
30 31 32 |
# File 'lib/floe/workflow/choice_rule.rb', line 30 def next @next end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
30 31 32 |
# File 'lib/floe/workflow/choice_rule.rb', line 30 def payload @payload end |
Class Method Details
.build(workflow, name, payload) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/floe/workflow/choice_rule.rb', line 9 def build(workflow, name, payload) if (sub_payloads = payload["Not"]) name += ["Not"] Floe::Workflow::ChoiceRule::Not.new(workflow, name, payload, build_children(workflow, name, [sub_payloads])) elsif (sub_payloads = payload["And"]) name += ["And"] Floe::Workflow::ChoiceRule::And.new(workflow, name, payload, build_children(workflow, name, sub_payloads)) elsif (sub_payloads = payload["Or"]) name += ["Or"] Floe::Workflow::ChoiceRule::Or.new(workflow, name, payload, build_children(workflow, name, sub_payloads)) else name += ["Data"] Floe::Workflow::ChoiceRule::Data.new(workflow, name, payload) end end |
.build_children(workflow, name, sub_payloads) ⇒ Object
25 26 27 |
# File 'lib/floe/workflow/choice_rule.rb', line 25 def build_children(workflow, name, sub_payloads) sub_payloads.map.with_index { |payload, i| build(workflow, name + [i.to_s], payload) } end |
Instance Method Details
#true? ⇒ Boolean
41 42 43 |
# File 'lib/floe/workflow/choice_rule.rb', line 41 def true?(*) raise NotImplementedError, "Must be implemented in a subclass" end |