Sha256: b531731f22ce187754da2e245094e5f84b1ce2c98d8c18561b06f12da8fb3ad1

Contents?: true

Size: 853 Bytes

Versions: 28

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

require 'set'

module SplitIoClient
  module Cache
    module Filter
      class FlagSetsFilter
        def initialize(flag_sets = [])
          @flag_sets = Set.new(flag_sets)
          @should_filter = @flag_sets.any?
        end

        def should_filter?
          @should_filter
        end

        def flag_set_exist?(flag_set)
          return true unless @should_filter

          if not flag_set.is_a?(String) or flag_set.empty?
            return false
          end

          @flag_sets.intersection([flag_set]).any?
        end

        def intersect?(flag_sets)
          return true unless @should_filter

          if not flag_sets.is_a?(Array) or flag_sets.empty?
            return false
          end

          @flag_sets.intersection(Set.new(flag_sets)).any?
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
splitclient-rb-8.5.0-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.5.0 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.5.0.pre.rc1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.5.0.pre.rc1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.1.pre.rc1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.1.pre.rc1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0.pre.rc1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0.pre.rc1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0.rc.1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.4.0.rc.1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.2.pre.rc2-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.2.pre.rc2 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.2.pre.rc1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.2.pre.rc1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.1 lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.1.pre.rc1-java lib/splitclient-rb/cache/filter/flag_set_filter.rb
splitclient-rb-8.3.1.pre.rc1 lib/splitclient-rb/cache/filter/flag_set_filter.rb