Class: SplitIoClient::EndsWithMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::EndsWithMatcher
- Defined in:
- lib/engine/matchers/ends_with_matcher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attribute, suffix_list) ⇒ EndsWithMatcher
constructor
A new instance of EndsWithMatcher.
- #match?(_key, data) ⇒ Boolean
Constructor Details
#initialize(attribute, suffix_list) ⇒ EndsWithMatcher
Returns a new instance of EndsWithMatcher.
7 8 9 10 |
# File 'lib/engine/matchers/ends_with_matcher.rb', line 7 def initialize(attribute, suffix_list) @attribute = attribute @suffix_list = suffix_list end |
Class Method Details
.matcher_type ⇒ Object
3 4 5 |
# File 'lib/engine/matchers/ends_with_matcher.rb', line 3 def self.matcher_type 'ENDS_WITH'.freeze end |
Instance Method Details
#match?(_key, data) ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/engine/matchers/ends_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 @suffix_list.empty? @suffix_list.any? { |suffix| value.to_s.end_with? suffix } end |