class SplitIoClient::Condition
acts as dto for a condition structure
def combiner
-
(object)- the combiner value for this condition
def combiner @data[:matcherGroup][:combiner] end
def create_condition_matcher(matchers)
def create_condition_matcher(matchers) CombiningMatcher.new(@config.split_logger, combiner, matchers) if combiner end
def empty?
-
(boolean)- true if the condition is empty false otherwise
def empty? @data.empty? end
def initialize(condition, config)
def initialize(condition, config) @data = condition @partitions = set_partitions @config = config end
def matcher
-
(object)- the matcher value for this condition
def matcher @data[:matcherGroup][:matchers].first[:matcherType] end
def matcher_all_keys(_params)
def matcher_all_keys(_params) @matcher_all_keys ||= AllKeysMatcher.new(@config.split_logger) end
def matcher_between(params)
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}, @config.split_logger, @config.split_validator) end
def matcher_contains_all_of_set(params)
def matcher_contains_all_of_set(params) ContainsAllMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_contains_any_of_set(params)
def matcher_contains_any_of_set(params) ContainsAnyMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_contains_string(params)
def matcher_contains_string(params) ContainsMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger, @config.split_validator ) end
def matcher_ends_with(params)
def matcher_ends_with(params) EndsWithMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_equal_to(params)
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}, @config.split_logger, @config.split_validator) end
def matcher_equal_to_boolean(params)
def matcher_equal_to_boolean(params) EqualToBooleanMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:booleanMatcherData], @config.split_logger ) end
def matcher_equal_to_set(params)
def matcher_equal_to_set(params) EqualToSetMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_greater_than_or_equal_to(params)
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}, @config.split_logger, @config.split_validator) end
def matcher_in_segment(params)
def matcher_in_segment(params) matcher = params[:matcher] segment_name = matcher[:userDefinedSegmentMatcherData] && matcher[:userDefinedSegmentMatcherData][:segmentName] UserDefinedSegmentMatcher.new(params[:segments_repository], segment_name, @config.split_logger) end
def matcher_in_split_treatment(params)
def matcher_in_split_treatment(params) DependencyMatcher.new( params[:matcher][:dependencyMatcherData][:split], params[:matcher][:dependencyMatcherData][:treatments], @config.split_logger ) end
def matcher_less_than_or_equal_to(params)
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}, @config.split_logger, @config.split_validator) end
def matcher_matches_string(params)
def matcher_matches_string(params) MatchesStringMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:stringMatcherData], @config.split_logger ) end
def matcher_part_of_set(params)
def matcher_part_of_set(params) PartOfSetMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_starts_with(params)
def matcher_starts_with(params) StartsWithMatcher.new( params[:matcher][:keySelector][:attribute], params[:matcher][:whitelistMatcherData][:whitelist], @config.split_logger ) end
def matcher_whitelist(params)
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, @config.split_logger, @config.split_validator) end
def matchers
-
(object)- the matchers array value for this condition
def matchers @data[:matcherGroup][:matchers] end
def negate
-
(object)- the negate value for this condition
def negate @data[:matcherGroup][:matchers].first[:negate] end
def negation_matcher(matcher)
def negation_matcher(matcher) NegationMatcher.new(@config.split_logger, matcher) end
def set_partitions
-
(void)-
def set_partitions partitions_list = [] @data[:partitions].each do |p| partition = SplitIoClient::Partition.new(p) partitions_list << partition end partitions_list end
def type
-
(string)- condition type
def type @data[:conditionType] end