Class: FeatureHub::Sdk::Impl::StringMatcher
- Inherits:
-
StrategyMatcher
- Object
- StrategyMatcher
- FeatureHub::Sdk::Impl::StringMatcher
- Defined in:
- lib/feature_hub/sdk/impl/strategy_wrappers.rb
Overview
matches for strings, dates and date-times
Instance Method Summary collapse
Instance Method Details
#match(supplied_value, attr) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/feature_hub/sdk/impl/strategy_wrappers.rb', line 32 def match(supplied_value, attr) vals = attr.str_values cond = attr.conditional if cond.equals? vals.any? { |v| supplied_value == v } elsif cond.not_equals? vals.none? { |v| supplied_value == v } elsif cond.ends_with? vals.any? { |v| supplied_value.end_with?(v) } elsif cond.starts_with? vals.any? { |v| supplied_value.start_with?(v) } elsif cond.greater? vals.any? { |v| supplied_value > v } elsif cond.greater_equals? vals.any? { |v| supplied_value >= v } elsif cond.less? vals.any? { |v| supplied_value < v } elsif cond.less_equals? vals.any? { |v| supplied_value <= v } elsif cond.includes? vals.any? { |v| supplied_value.include?(v) } elsif cond.excludes? vals.none? { |v| supplied_value.include?(v) } elsif cond.regex? vals.any? { |v| !Regexp.new(v).match(supplied_value).nil? } else false end end |