Class: SplitIoClient::Helpers::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/helpers/util.rb

Class Method Summary collapse

Class Method Details

.segment_names_by_object(object, matcher_type) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/splitclient-rb/helpers/util.rb', line 6

def self.segment_names_by_object(object, matcher_type)
  object[:conditions].each_with_object(Set.new) do |condition, names|
    condition[:matcherGroup][:matchers].each do |matcher|
      next if matcher[:userDefinedSegmentMatcherData].nil? || matcher[:matcherType] != matcher_type

      names << matcher[:userDefinedSegmentMatcherData][:segmentName]
    end
  end
end

.segment_names_in_rb_segment(object, matcher_type) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/splitclient-rb/helpers/util.rb', line 16

def self.segment_names_in_rb_segment(object, matcher_type)
  names = Set.new
  names.merge segment_names_by_object(object, matcher_type)
  object[:excluded][:segments].each do |segment|
    names.add(segment[:name]) if segment[:type] == SplitIoClient::Engine::Models::SegmentType::STANDARD
  end
  names
end