Class: Flagsmith::Engine::Segments::Rule
- Inherits:
-
Object
- Object
- Flagsmith::Engine::Segments::Rule
- Includes:
- Constants
- Defined in:
- lib/flagsmith/engine/segments/models.rb
Overview
SegmentRuleModel
Constant Summary collapse
Constants included from Constants
Constants::ALL_RULE, Constants::ANY_RULE, Constants::CONDITION_OPERATORS, Constants::CONTAINS, Constants::EQUAL, Constants::GREATER_THAN, Constants::GREATER_THAN_INCLUSIVE, Constants::IN, Constants::IS_NOT_SET, Constants::IS_SET, Constants::LESS_THAN, Constants::LESS_THAN_INCLUSIVE, Constants::MODULO, Constants::NONE_RULE, Constants::NOT_CONTAINS, Constants::NOT_EQUAL, Constants::PERCENTAGE_SPLIT, Constants::REGEX, Constants::RULE_TYPES
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#rules ⇒ Object
Returns the value of attribute rules.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type: nil, rules: [], conditions: []) ⇒ Rule
constructor
A new instance of Rule.
- #matching_function ⇒ Object
Constructor Details
#initialize(type: nil, rules: [], conditions: []) ⇒ Rule
Returns a new instance of Rule.
114 115 116 117 118 |
# File 'lib/flagsmith/engine/segments/models.rb', line 114 def initialize(type: nil, rules: [], conditions: []) @type = type @rules = rules @conditions = conditions end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
112 113 114 |
# File 'lib/flagsmith/engine/segments/models.rb', line 112 def conditions @conditions end |
#rules ⇒ Object
Returns the value of attribute rules.
112 113 114 |
# File 'lib/flagsmith/engine/segments/models.rb', line 112 def rules @rules end |
#type ⇒ Object
Returns the value of attribute type.
112 113 114 |
# File 'lib/flagsmith/engine/segments/models.rb', line 112 def type @type end |
Class Method Details
.build(json) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/flagsmith/engine/segments/models.rb', line 125 def build(json) rules = json.fetch(:rules, []).map { |r| Flagsmith::Engine::Segments::Rule.build(r) } conditions = json.fetch(:conditions, []).map { |c| Flagsmith::Engine::Segments::Condition.build(c) } new( type: json[:type], rules: rules, conditions: conditions ) end |
Instance Method Details
#matching_function ⇒ Object
120 121 122 |
# File 'lib/flagsmith/engine/segments/models.rb', line 120 def matching_function MATCHING_FUNCTIONS[type] end |