Class: Floe::Workflow::ChoiceRule::Data
- Inherits:
-
Floe::Workflow::ChoiceRule
- Object
- Floe::Workflow::ChoiceRule
- Floe::Workflow::ChoiceRule::Data
- Defined in:
- lib/floe/workflow/choice_rule/data.rb
Constant Summary collapse
- TYPES =
["String", "Numeric", "Boolean", "Timestamp", "Present", "Null"].freeze
- COMPARES =
["Equals", "LessThan", "GreaterThan", "LessThanEquals", "GreaterThanEquals", "Matches"].freeze
- TYPE_CHECK =
e.g.: (Is)(String), (Is)(Present)
/^(Is)(#{TYPES.join("|")})$/.freeze
- OPERATION =
e.g.: (String)(LessThan)(Path), (Numeric)(GreaterThanEquals)()
/^(#{(TYPES - %w[Null Present]).join("|")})(#{COMPARES.join("|")})(Path)?$/.freeze
Instance Attribute Summary collapse
-
#compare_key ⇒ Object
readonly
Returns the value of attribute compare_key.
-
#compare_predicate ⇒ Object
readonly
Returns the value of attribute compare_predicate.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Attributes inherited from Floe::Workflow::ChoiceRule
#children, #name, #next, #payload
Instance Method Summary collapse
-
#initialize(_workflow, _name, payload) ⇒ Data
constructor
A new instance of Data.
- #true?(context, input) ⇒ Boolean
Methods inherited from Floe::Workflow::ChoiceRule
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) ⇒ Data
Returns a new instance of Data.
16 17 18 19 20 21 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 16 def initialize(_workflow, _name, payload) super @variable = parse_path("Variable") parse_compare_key end |
Instance Attribute Details
#compare_key ⇒ Object (readonly)
Returns the value of attribute compare_key.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def compare_key @compare_key end |
#compare_predicate ⇒ Object (readonly)
Returns the value of attribute compare_predicate.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def compare_predicate @compare_predicate end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def operation @operation end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def type @type end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
14 15 16 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 14 def variable @variable end |
Instance Method Details
#true?(context, input) ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/floe/workflow/choice_rule/data.rb', line 23 def true?(context, input) return presence_check(context, input) if compare_key == "IsPresent" lhs = variable_value(context, input) rhs = compare_value(context, input) send(operation, lhs, rhs) end |