Class: SplitIoClient::SplitManager
- Inherits:
-
Object
- Object
- SplitIoClient::SplitManager
- Defined in:
- lib/splitclient-rb/managers/split_manager.rb
Instance Method Summary collapse
- #build_split_view(name, split) ⇒ Object
-
#initialize(api_key, config = {}, adapter = nil, splits_repository = nil) ⇒ SplitIoManager
constructor
Creates a new split manager instance that connects to split.io API.
-
#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.
Constructor Details
#initialize(api_key, config = {}, adapter = nil, splits_repository = nil) ⇒ SplitIoManager
Creates a new split manager instance that connects to split.io API.
9 10 11 12 13 14 |
# File 'lib/splitclient-rb/managers/split_manager.rb', line 9 def initialize(api_key, config = {}, adapter = nil, splits_repository = nil) @localhost_mode_features = [] @config = config @splits_repository = splits_repository @adapter = adapter end |
Instance Method Details
#build_split_view(name, split) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/splitclient-rb/managers/split_manager.rb', line 55 def build_split_view(name, split) return {} unless split treatments = if split[:conditions] && split[:conditions][0][:partitions] split[:conditions][0][:partitions].map { |partition| partition[:treatment] } else [] end { name: name, traffic_type_name: split[:trafficTypeName], killed: split[:killed], treatments: treatments, change_number: split[:changeNumber] } end |
#split(split_name) ⇒ Object
method to get a split view
47 48 49 50 51 52 53 |
# File 'lib/splitclient-rb/managers/split_manager.rb', line 47 def split(split_name) if @splits_repository split = @splits_repository.get_split(split_name) build_split_view(split_name, split) unless split.nil? or split_model(split).archived? end end |
#split_names ⇒ Object
method to get the list of just split names. Ideal for ietrating and calling client.get_treatment
37 38 39 40 41 |
# File 'lib/splitclient-rb/managers/split_manager.rb', line 37 def split_names return if @splits_repository.nil? @splits_repository.split_names end |
#splits ⇒ Object
method to get the split list from the client
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/splitclient-rb/managers/split_manager.rb', line 20 def splits return if @splits_repository.nil? @splits_repository.splits.each_with_object([]) do |(name, split), memo| split_model = Engine::Models::Split.new(split) split_view = build_split_view(name, split) next if split_view[:name] == nil memo << split_view unless split_model.archived? end end |