Exception: SplitIoClient::UserDefinedSegmentMatcher

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/engine/matchers/user_defined_segment_matcher.rb

Overview

class to implement the user defined matcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segments_repository, segment_name) ⇒ UserDefinedSegmentMatcher

Returns a new instance of UserDefinedSegmentMatcher.



10
11
12
13
14
# File 'lib/engine/matchers/user_defined_segment_matcher.rb', line 10

def initialize(segments_repository, segment_name)
  @matcher_type = "IN_SEGMENT"
  @segments_repository = segments_repository
  @segment_name = segment_name
end

Instance Attribute Details

#matcher_typeObject (readonly)

Returns the value of attribute matcher_type.



8
9
10
# File 'lib/engine/matchers/user_defined_segment_matcher.rb', line 8

def matcher_type
  @matcher_type
end

Instance Method Details

#equals?(obj) ⇒ Boolean

evaluates if the given object equals the matcher

Parameters:

  • obj (object)

    object to be evaluated

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/engine/matchers/user_defined_segment_matcher.rb', line 32

def equals?(obj)
  if obj.nil?
    false
  elsif !obj.instance_of?(UserDefinedSegmentMatcher)
    false
  elsif self.equal?(obj)
    true
  else
    false
  end
end

#match?(key, attributes) ⇒ boolean

evaluates if the key matches the matcher

Parameters:

  • key (string)

    key value to be matched

Returns:

  • (boolean)

    evaluation of the key against the segment



22
23
24
# File 'lib/engine/matchers/user_defined_segment_matcher.rb', line 22

def match?(key, attributes)
  @segments_repository.in_segment?(@segment_name, key)
end