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'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, boolean) ⇒ EqualToBooleanMatcher

Returns a new instance of EqualToBooleanMatcher.



9
10
11
12
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 9

def initialize(attribute, boolean)
  @attribute = attribute
  @boolean = boolean
end

Instance Attribute Details

#attribute ⇒ Object (readonly)

Returns the value of attribute attribute.



7
8
9
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 7

def attribute
  @attribute
end

Instance Method Details

#match?(args) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
# File 'lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb', line 14

def match?(args)
  value = get_value(args)
  value = false if value.to_s.casecmp('false').zero?
  value = true if value.to_s.casecmp('true').zero?

  matches = value == @boolean
  SplitLogger.log_if_debug("[EqualToBooleanMatcher] #{value} equals to #{@boolean} -> #{matches}")
  matches
end

#string_type? ⇒ Boolean

Returns:

  • (Boolean)


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

def string_type?
  false
end