Class: SplitIoClient::InListSemverMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'IN_LIST_SEMVER'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, list_value, logger, validator) ⇒ InListSemverMatcher
constructor
A new instance of InListSemverMatcher.
- #match?(args) ⇒ Boolean
Methods inherited from Matcher
Constructor Details
#initialize(attribute, list_value, logger, validator) ⇒ InListSemverMatcher
Returns a new instance of InListSemverMatcher.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb', line 9 def initialize(attribute, list_value, logger, validator) super(logger) @validator = validator @attribute = attribute @semver_list = [] list_value.map do |item| version = SplitIoClient::Semver.build(item, logger) @semver_list << version unless version.nil? end @logger = logger end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
7 8 9 |
# File 'lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb', line 7 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb', line 22 def match?(args) return false if @semver_list.empty? || !verify_semver_arg?(args, 'InListSemverMatcher') value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) if value_to_match.nil? @logger.error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type') return false end matches = (@semver_list.map { |item| item.version == value_to_match.version }).any? { |item| item == true } @logger.debug("[InListSemverMatcher] #{value_to_match} matches -> #{matches}") matches end |