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, logger) ⇒ EqualToBooleanMatcher

Returns a new instance of EqualToBooleanMatcher.



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

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

Instance Attribute Details

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


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

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
  @logger.log_if_debug("[EqualToBooleanMatcher] #{value} equals to #{@boolean} -> #{matches}")
  matches
end

#string_type?Boolean

Returns:

  • (Boolean)


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

def string_type?
  false
end