Class: DecisionAgent::Dmn::DecisionTable
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::DecisionTable
- Defined in:
- lib/decision_agent/dmn/model.rb
Overview
Decision table with inputs, outputs, rules, and hit policy
Constant Summary collapse
- VALID_HIT_POLICIES =
%w[UNIQUE FIRST PRIORITY ANY COLLECT].freeze
Instance Attribute Summary collapse
-
#hit_policy ⇒ Object
readonly
Returns the value of attribute hit_policy.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #add_input(input) ⇒ Object
- #add_output(output) ⇒ Object
- #add_rule(rule) ⇒ Object
- #freeze ⇒ Object
-
#initialize(id:, hit_policy: "UNIQUE") ⇒ DecisionTable
constructor
A new instance of DecisionTable.
Constructor Details
#initialize(id:, hit_policy: "UNIQUE") ⇒ DecisionTable
Returns a new instance of DecisionTable.
75 76 77 78 79 80 81 82 |
# File 'lib/decision_agent/dmn/model.rb', line 75 def initialize(id:, hit_policy: "UNIQUE") @id = id.to_s validate_hit_policy!(hit_policy) @hit_policy = hit_policy.to_s @inputs = [] @outputs = [] @rules = [] end |
Instance Attribute Details
#hit_policy ⇒ Object (readonly)
Returns the value of attribute hit_policy.
71 72 73 |
# File 'lib/decision_agent/dmn/model.rb', line 71 def hit_policy @hit_policy end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
71 72 73 |
# File 'lib/decision_agent/dmn/model.rb', line 71 def id @id end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
71 72 73 |
# File 'lib/decision_agent/dmn/model.rb', line 71 def inputs @inputs end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
71 72 73 |
# File 'lib/decision_agent/dmn/model.rb', line 71 def outputs @outputs end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
71 72 73 |
# File 'lib/decision_agent/dmn/model.rb', line 71 def rules @rules end |
Instance Method Details
#add_input(input) ⇒ Object
84 85 86 87 88 |
# File 'lib/decision_agent/dmn/model.rb', line 84 def add_input(input) raise TypeError, "Expected Input, got #{input.class}" unless input.is_a?(Input) @inputs << input end |
#add_output(output) ⇒ Object
90 91 92 93 94 |
# File 'lib/decision_agent/dmn/model.rb', line 90 def add_output(output) raise TypeError, "Expected Output, got #{output.class}" unless output.is_a?(Output) @outputs << output end |
#add_rule(rule) ⇒ Object
96 97 98 99 100 |
# File 'lib/decision_agent/dmn/model.rb', line 96 def add_rule(rule) raise TypeError, "Expected Rule, got #{rule.class}" unless rule.is_a?(Rule) @rules << rule end |
#freeze ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/decision_agent/dmn/model.rb', line 102 def freeze @id.freeze @hit_policy.freeze @inputs.each(&:freeze) @inputs.freeze @outputs.each(&:freeze) @outputs.freeze @rules.each(&:freeze) @rules.freeze super end |