Sha256: a86d7a5bf4cd56c265907f1ebd294fcd34a6ec42c139961d8bcfa7cb0cb19aac
Contents?: true
Size: 823 Bytes
Versions: 300
Compression:
Stored size: 823 Bytes
Contents
# frozen_string_literal: true module SplitIoClient class EqualToBooleanMatcher MATCHER_TYPE = 'EQUAL_TO_BOOLEAN' attr_reader :attribute def initialize(attribute, boolean, logger) @attribute = attribute @boolean = boolean @logger = logger end 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 def string_type? false end private def get_value(args) args[:attributes].fetch(@attribute) do |a| args[:attributes][a.to_s] || args[:attributes][a.to_sym] end end end end
Version data entries
300 entries across 300 versions & 1 rubygems