Class: Smplkit::Flags::FlagRule
- Inherits:
-
Object
- Object
- Smplkit::Flags::FlagRule
- Defined in:
- lib/smplkit/flags/models.rb
Overview
A single targeting rule on a Flag.
Lives in FlagEnvironment#rules. Frozen — author rules via the Smplkit::Rule fluent builder and pass through Flag#add_rule.
Attributes:
- logic: JSON Logic predicate. Empty Hash means "always match".
- value: Value to serve when +logic+ evaluates truthy.
- description: Human-readable label (optional).
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#logic ⇒ Object
readonly
Returns the value of attribute logic.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(logic:, value: nil, description: nil) ⇒ FlagRule
constructor
A new instance of FlagRule.
Constructor Details
#initialize(logic:, value: nil, description: nil) ⇒ FlagRule
Returns a new instance of FlagRule.
23 24 25 26 27 28 |
# File 'lib/smplkit/flags/models.rb', line 23 def initialize(logic:, value: nil, description: nil) @logic = logic @value = value @description = description freeze end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
21 22 23 |
# File 'lib/smplkit/flags/models.rb', line 21 def description @description end |
#logic ⇒ Object (readonly)
Returns the value of attribute logic.
21 22 23 |
# File 'lib/smplkit/flags/models.rb', line 21 def logic @logic end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
21 22 23 |
# File 'lib/smplkit/flags/models.rb', line 21 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 |
# File 'lib/smplkit/flags/models.rb', line 30 def ==(other) other.is_a?(FlagRule) && logic == other.logic && value == other.value && description == other.description end |
#hash ⇒ Object
35 |
# File 'lib/smplkit/flags/models.rb', line 35 def hash = [logic, value, description].hash |