Class: SplitIoClient::StartsWithMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::StartsWithMatcher
- Defined in:
- lib/engine/matchers/starts_with_matcher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attribute, prefix_list) ⇒ StartsWithMatcher
constructor
A new instance of StartsWithMatcher.
- #match?(_key, data) ⇒ Boolean
Constructor Details
#initialize(attribute, prefix_list) ⇒ StartsWithMatcher
Returns a new instance of StartsWithMatcher.
7 8 9 10 |
# File 'lib/engine/matchers/starts_with_matcher.rb', line 7 def initialize(attribute, prefix_list) @attribute = attribute @prefix_list = prefix_list end |
Class Method Details
.matcher_type ⇒ Object
3 4 5 |
# File 'lib/engine/matchers/starts_with_matcher.rb', line 3 def self.matcher_type 'STARTS_WITH'.freeze end |
Instance Method Details
#match?(_key, data) ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/engine/matchers/starts_with_matcher.rb', line 12 def match?(_key, data) value = data.fetch(@attribute) { |attr| data[attr.to_s] || data[attr.to_sym] } return false if @prefix_list.empty? @prefix_list.any? { |prefix| value.to_s.start_with? prefix } end |