Class: SplitIoClient::EqualToMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/equal_to_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'EQUAL_TO'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute_hash, logger, validator) ⇒ EqualToMatcher
constructor
A new instance of EqualToMatcher.
- #match?(args) ⇒ Boolean
Methods inherited from Matcher
Constructor Details
#initialize(attribute_hash, logger, validator) ⇒ EqualToMatcher
Returns a new instance of EqualToMatcher.
9 10 11 12 13 14 15 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_matcher.rb', line 9 def initialize(attribute_hash, logger, validator) super(logger) @validator = validator @attribute = attribute_hash[:attribute] @data_type = attribute_hash[:data_type] @value = formatted_value(attribute_hash[:value], true) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
7 8 9 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_matcher.rb', line 7 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_matcher.rb', line 17 def match?(args) @logger.log_if_debug('[EqualsToMatcher] evaluating value and attributes.') return false unless @validator.valid_matcher_arguments(args) value = formatted_value(args[:value] || args[:attributes][@attribute.to_sym]) matches = value.is_a?(Integer) ? (value == @value) : false @logger.log_if_debug("[EqualsToMatcher] #{value} equals to #{@value} -> #{matches}") matches end |