Class: SplitIoClient::WhitelistMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/whitelist_matcher.rb
Overview
class to implement the user defined matcher
Constant Summary collapse
- MATCHER_TYPE =
'WHITELIST_MATCHER'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(whitelist_data, logger, validator) ⇒ WhitelistMatcher
constructor
A new instance of WhitelistMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
-
#to_s ⇒ string
function to print string value for this matcher.
Methods inherited from Matcher
Constructor Details
#initialize(whitelist_data, logger, validator) ⇒ WhitelistMatcher
Returns a new instance of WhitelistMatcher.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/splitclient-rb/engine/matchers/whitelist_matcher.rb', line 12 def initialize(whitelist_data, logger, validator) super(logger) @validator = validator @whitelist = case whitelist_data when Array whitelist_data when Hash @matcher_type = 'ATTR_WHITELIST' @attribute = whitelist_data[:attribute] whitelist_data[:value] else [] end end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
10 11 12 |
# File 'lib/splitclient-rb/engine/matchers/whitelist_matcher.rb', line 10 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
28 29 30 31 32 33 34 35 36 |
# File 'lib/splitclient-rb/engine/matchers/whitelist_matcher.rb', line 28 def match?(args) return matches_user_whitelist(args) unless @matcher_type == 'ATTR_WHITELIST' @logger.log_if_debug('[WhitelistMatcher] evaluating value and attributes.') return false unless @validator.valid_matcher_arguments(args) matches_attr_whitelist(args) end |
#string_type? ⇒ Boolean
38 39 40 |
# File 'lib/splitclient-rb/engine/matchers/whitelist_matcher.rb', line 38 def string_type? true end |
#to_s ⇒ string
function to print string value for this matcher
46 47 48 |
# File 'lib/splitclient-rb/engine/matchers/whitelist_matcher.rb', line 46 def to_s "in segment #{@whitelist}" end |