Sha256: ade585144e26a06b8ac3f68f312ff7ee7d138b75d010079139023a50afb84e81
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module SplitIoClient # # class to implement the user defined matcher # class WhitelistMatcher < NoMethodError attr_reader :matcher_type # variable that contains the keys of the whitelist @whitelist = [] def initialize(whitelist_data) if whitelist_data.instance_of? Array @whitelist = whitelist_data unless whitelist_data.nil? elsif whitelist_data.instance_of? Hash @matcher_type = "ATTR_WHITELIST" @attribute = whitelist_data[:attribute] @whitelist = whitelist_data[:value] unless whitelist_data[:value].nil? end end def match?(value, _matching_key, _bucketing_key, _evaluator) matches = false if !value.nil? matches = @whitelist.include?(value) end matches end # # evaluates if the given object equals the matcher # # @param obj [object] object to be evaluated # # @returns [boolean] true if obj equals the matcher def equals?(obj) if obj.nil? false elsif !obj.instance_of?(WhitelistMatcher) false elsif self.equal?(obj) true else false end end # # function to print string value for this matcher # # @reutrn [string] string value of this matcher def to_s 'in segment ' + @whitelist.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
splitclient-rb-4.3.0.canary.2 | lib/splitclient-rb/engine/matchers/whitelist_matcher.rb |
splitclient-rb-4.3.0.canary.1 | lib/splitclient-rb/engine/matchers/whitelist_matcher.rb |