Sha256: 30a5ac18ceb37e431a786e5ca388d4b8c19da9b9022f8a305deb3211b50f4e7c
Contents?: true
Size: 889 Bytes
Versions: 28
Compression:
Stored size: 889 Bytes
Contents
# frozen_string_literal: true module SplitIoClient class StartsWithMatcher MATCHER_TYPE = 'STARTS_WITH' attr_reader :attribute def initialize(attribute, prefix_list) @attribute = attribute @prefix_list = prefix_list end def match?(args) if @prefix_list.empty? SplitLogger.log_if_debug('[StartsWithMatcher] Prefix List is empty.') return false end value = get_value(args) matches = @prefix_list.any? { |prefix| value.to_s.start_with? prefix } SplitLogger.log_if_debug("[StartsWithMatcher] #{value} matches any of #{@prefix_list} -> #{matches}") matches end def string_type? true end private def get_value(args) args[:value] || args[:attributes].fetch(@attribute) do |a| args[:attributes][a.to_s] || args[:attributes][a.to_sym] end end end end
Version data entries
28 entries across 28 versions & 1 rubygems