Class: SplitIoClient::EqualToBooleanMatcher

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#attributeObject (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

Returns:

  • (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

Returns:

  • (Boolean)


23
24
25
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 23

def string_type?
  false
end