Class: SplitIoClient::StartsWithMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::StartsWithMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/starts_with_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'STARTS_WITH'.freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, prefix_list) ⇒ StartsWithMatcher
constructor
A new instance of StartsWithMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
Constructor Details
#initialize(attribute, prefix_list) ⇒ StartsWithMatcher
Returns a new instance of StartsWithMatcher.
7 8 9 10 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 7 def initialize(attribute, prefix_list) @attribute = attribute @prefix_list = prefix_list end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 5 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
12 13 14 15 16 17 18 19 20 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 12 def match?(args) value = args[:value] || args[:attributes].fetch(@attribute) do |a| args[:attributes][a.to_s] || args[:attributes][a.to_sym] end return false if @prefix_list.empty? @prefix_list.any? { |prefix| value.to_s.start_with? prefix } end |
#string_type? ⇒ Boolean
22 23 24 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 22 def string_type? true end |