Sha256: de90f43c8784e8d53356da8a7612de27eb734d4f9ad8e09d4c6b9c70df19cb83
Contents?: true
Size: 1.14 KB
Versions: 294
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module SplitIoClient class EqualToMatcher < Matcher MATCHER_TYPE = 'EQUAL_TO' attr_reader :attribute def initialize(attribute_hash, logger, validator) super(logger) @validator = validator @attribute = attribute_hash[:attribute] @data_type = attribute_hash[:data_type] @value = formatted_value(attribute_hash[:value], true) end def match?(args) @logger.log_if_debug('[EqualsToMatcher] evaluating value and attributes.') return false unless @validator.valid_matcher_arguments(args) value = formatted_value(args[:value] || args[:attributes][@attribute.to_sym]) matches = value.is_a?(Integer) ? (value == @value) : false @logger.log_if_debug("[EqualsToMatcher] #{value} equals to #{@value} -> #{matches}") matches end private def formatted_value(value, sdk_data = false) case @data_type when 'NUMBER' value when 'DATETIME' value /= 1000 if sdk_data SplitIoClient::Utilities.to_milis_zero_out_from_hour value else @logger.error('Invalid data type') end end end end
Version data entries
294 entries across 294 versions & 1 rubygems