Class: SplitIoClient::LocalhostSplitManager

Inherits:
Object
  • Object
show all
Includes:
LocalhostUtils
Defined in:
lib/splitclient-rb/managers/localhost_split_manager.rb

Instance Method Summary collapse

Methods included from LocalhostUtils

#load_localhost_mode_features, #store_features

Constructor Details

#initialize(splits_file, reload_rate = nil) ⇒ LocalhostSplitIoManager

Creates a new split manager instance that holds the splits from a given file

Parameters:

  • splits_file (File)

    the .split file that contains the splits

  • reload_rate (Integer) (defaults to: nil)

    the number of seconds to reload splits_file



12
13
14
15
16
17
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 12

def initialize(splits_file, reload_rate = nil)
  @localhost_mode = true
  @localhost_mode_features = []

  load_localhost_mode_features(splits_file, reload_rate)
end

Instance Method Details

#split(split_name) ⇒ Object

method to get a split view



23
24
25
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 23

def split(split_name)
  @localhost_mode_features.find { |x| x[:feature] == split_name }
end

#split_namesObject

method to get the list of just split names. Ideal for ietrating and calling client.get_treatment



39
40
41
42
43
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 39

def split_names
  @localhost_mode_features.each_with_object([]) do |split, memo|
    memo << split[:feature]
  end
end

#splitsObject

method to get the split list from the client



31
32
33
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 31

def splits
  @localhost_mode_features
end