Class: SplitIoClient::LocalhostSplitManager
- Inherits:
-
Object
- Object
- SplitIoClient::LocalhostSplitManager
- Includes:
- LocalhostUtils
- Defined in:
- lib/splitclient-rb/managers/localhost_split_manager.rb
Instance Method Summary collapse
-
#initialize(splits_file, reload_rate = nil) ⇒ LocalhostSplitIoManager
constructor
Creates a new split manager instance that holds the splits from a given file.
-
#split(split_name) ⇒ Object
method to get a split view.
-
#split_names ⇒ Object
method to get the list of just split names.
-
#splits ⇒ Object
method to get the split list from the client.
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
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 23 def split(split_name) features = @localhost_mode_features.find_all { |feat| feat[:feature] == split_name } return nil if features.nil? treatments = features.map { |feat| feat[:treatment] } configs = Hash[ features.map { |feat| [ feat[:treatment].to_sym, feat[:config] ] } ] { change_number: nil, killed: false, name: split_name, traffic_type: nil, treatments: treatments, configs: configs } end |
#split_names ⇒ Object
method to get the list of just split names. Ideal for ietrating and calling client.get_treatment
56 57 58 |
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 56 def split_names @localhost_mode_features.map{ |feat| feat[:feature]}.uniq end |
#splits ⇒ Object
method to get the split list from the client
46 47 48 49 50 |
# File 'lib/splitclient-rb/managers/localhost_split_manager.rb', line 46 def splits split_names.map do |split_name| split(split_name) end end |