Sha256: 71c6e2598e879ce988f8d3ad1e38363aab61100b85b7854dbdb6a561e8fbea0a
Contents?: true
Size: 852 Bytes
Versions: 1
Compression:
Stored size: 852 Bytes
Contents
# frozen_string_literal: true module Intercept module Strategy class Mapper attr_reader :bucket_map, :fallback_strategy def initialize(bucket_map, fallback_strategy = nil) @bucket_map = bucket_map @fallback_strategy = fallback_strategy end def process_identities(identities) return [] if identities.blank? mapped_identities = map_identities(identities) if fallback_strategy && mapped_identities.empty? fallback_strategy.process_identities(identities) else mapped_identities end end private def map_identities(identities) identities.map do |identity| bucket_map.find do |bucket, _| Regexp.new(bucket).match?(identity) end&.second end.compact.uniq end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
intercept-0.2.0 | lib/intercept/strategy/mapper.rb |