Exception: SplitIoClient::Condition
- Inherits:
-
NoMethodError
- Object
- NoMethodError
- SplitIoClient::Condition
- Defined in:
- lib/engine/parser/condition.rb
Overview
acts as dto for a condition structure
Instance Attribute Summary collapse
-
#data ⇒ Object
definition of the condition.
Instance Method Summary collapse
-
#combiner ⇒ object
The combiner value for this condition.
- #create_condition_matcher(matchers) ⇒ Object
-
#empty? ⇒ boolean
True if the condition is empty false otherwise.
-
#initialize(condition) ⇒ Condition
constructor
A new instance of Condition.
-
#matcher ⇒ object
The matcher value for this condition.
- #matcher_all_keys(params) ⇒ Object
- #matcher_between(params) ⇒ Object
- #matcher_equal_to(params) ⇒ Object
- #matcher_greater_than_or_equal_to(params) ⇒ Object
-
#matcher_in_segment(params) ⇒ Object
returns UserDefinedSegmentMatcher.
- #matcher_less_than_or_equal_to(params) ⇒ Object
-
#matcher_whitelist(params) ⇒ Object
returns WhitelistMatcher the whitelist for this condition in case it has a whitelist matcher.
-
#matchers ⇒ object
The matchers array value for this condition.
-
#negate ⇒ object
The negate value for this condition.
-
#partitions ⇒ object
The array of partitions for this condition.
-
#set_partitions ⇒ void
converts the partitions hash for this condition into an array of partition objects.
Constructor Details
#initialize(condition) ⇒ Condition
Returns a new instance of Condition.
14 15 16 17 |
# File 'lib/engine/parser/condition.rb', line 14 def initialize(condition) @data = condition @partitions = set_partitions end |
Instance Attribute Details
#data ⇒ Object
definition of the condition
12 13 14 |
# File 'lib/engine/parser/condition.rb', line 12 def data @data end |
Instance Method Details
#combiner ⇒ object
Returns the combiner value for this condition.
25 26 27 |
# File 'lib/engine/parser/condition.rb', line 25 def combiner @data[:matcherGroup][:combiner] end |
#create_condition_matcher(matchers) ⇒ Object
19 20 21 |
# File 'lib/engine/parser/condition.rb', line 19 def create_condition_matcher matchers CombiningMatcher.new(combiner, matchers) unless combiner.nil? end |
#empty? ⇒ boolean
Returns true if the condition is empty false otherwise.
128 129 130 |
# File 'lib/engine/parser/condition.rb', line 128 def empty? @data.empty? end |
#matcher ⇒ object
Returns the matcher value for this condition.
31 32 33 |
# File 'lib/engine/parser/condition.rb', line 31 def matcher @data[:matcherGroup][:matchers].first[:matcherType] end |
#matcher_all_keys(params) ⇒ Object
41 42 43 |
# File 'lib/engine/parser/condition.rb', line 41 def matcher_all_keys params AllKeysMatcher.new end |
#matcher_between(params) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/engine/parser/condition.rb', line 92 def matcher_between params matcher = params[:matcher] attribute = (matcher[:keySelector])[:attribute] start_value = (matcher[:betweenMatcherData])[:start] end_value = (matcher[:betweenMatcherData])[:end] data_type = (matcher[:betweenMatcherData])[:dataType] BetweenMatcher.new({attribute: attribute, start_value: start_value, end_value: end_value, data_type: data_type}) end |
#matcher_equal_to(params) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/engine/parser/condition.rb', line 68 def matcher_equal_to params matcher = params[:matcher] attribute = (matcher[:keySelector])[:attribute] value = (matcher[:unaryNumericMatcherData])[:value] data_type = (matcher[:unaryNumericMatcherData])[:dataType] EqualToMatcher.new({attribute: attribute, value: value, data_type: data_type}) end |
#matcher_greater_than_or_equal_to(params) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/engine/parser/condition.rb', line 76 def matcher_greater_than_or_equal_to params matcher = params[:matcher] attribute = (matcher[:keySelector])[:attribute] value = (matcher[:unaryNumericMatcherData])[:value] data_type = (matcher[:unaryNumericMatcherData])[:dataType] GreaterThanOrEqualToMatcher.new({attribute: attribute, value: value, data_type: data_type}) end |
#matcher_in_segment(params) ⇒ Object
returns UserDefinedSegmentMatcher
46 47 48 49 50 51 |
# File 'lib/engine/parser/condition.rb', line 46 def matcher_in_segment params matcher = params[:matcher] segment_name = matcher[:userDefinedSegmentMatcherData] && matcher[:userDefinedSegmentMatcherData][:segmentName] UserDefinedSegmentMatcher.new(params[:segments_repository], segment_name) end |
#matcher_less_than_or_equal_to(params) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/engine/parser/condition.rb', line 84 def matcher_less_than_or_equal_to params matcher = params[:matcher] attribute = (matcher[:keySelector])[:attribute] value = (matcher[:unaryNumericMatcherData])[:value] data_type = (matcher[:unaryNumericMatcherData])[:dataType] LessThanOrEqualToMatcher.new({attribute: attribute, value: value, data_type: data_type}) end |
#matcher_whitelist(params) ⇒ Object
returns WhitelistMatcher the whitelist for this condition in case it has a whitelist matcher
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/engine/parser/condition.rb', line 54 def matcher_whitelist params result = nil matcher = params[:matcher] is_user_whitelist = ((matcher[:keySelector]).nil? || (matcher[:keySelector])[:attribute].nil?) if is_user_whitelist result = (matcher[:whitelistMatcherData])[:whitelist] else attribute = (matcher[:keySelector])[:attribute] white_list = (matcher[:whitelistMatcherData])[:whitelist] result = {attribute: attribute, value: white_list} end WhitelistMatcher.new(result) end |
#matchers ⇒ object
Returns the matchers array value for this condition.
37 38 39 |
# File 'lib/engine/parser/condition.rb', line 37 def matchers @data[:matcherGroup][:matchers] end |
#negate ⇒ object
Returns the negate value for this condition.
103 104 105 |
# File 'lib/engine/parser/condition.rb', line 103 def negate @data[:matcherGroup][:matchers].first[:negate] end |
#partitions ⇒ object
Returns the array of partitions for this condition.
109 110 111 |
# File 'lib/engine/parser/condition.rb', line 109 def partitions @partitions end |
#set_partitions ⇒ void
This method returns an undefined value.
converts the partitions hash for this condition into an array of partition objects
117 118 119 120 121 122 123 124 |
# File 'lib/engine/parser/condition.rb', line 117 def set_partitions partitions_list = [] @data[:partitions].each do |p| partition = SplitIoClient::Partition.new(p) partitions_list << partition end partitions_list end |