Class: SplitIoClient::EqualToBooleanMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::EqualToBooleanMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'EQUAL_TO_BOOLEAN'.freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, boolean) ⇒ EqualToBooleanMatcher
constructor
A new instance of EqualToBooleanMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
Constructor Details
#initialize(attribute, boolean) ⇒ EqualToBooleanMatcher
Returns a new instance of EqualToBooleanMatcher.
7 8 9 10 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 7 def initialize(attribute, boolean) @attribute = attribute @boolean = boolean end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 5 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 12 def match?(args) value = args[:attributes].fetch(@attribute) do |a| args[:attributes][a.to_s] || args[:attributes][a.to_sym] end value = false if value.to_s.downcase == 'false' value = true if value.to_s.downcase == 'true' value == @boolean end |
#string_type? ⇒ Boolean
23 24 25 |
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 23 def string_type? false end |