Class: TestTrack::SplitRegistry

Inherits:
Object
  • Object
show all
Defined in:
app/models/test_track/split_registry.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry_hash) ⇒ SplitRegistry

Returns a new instance of SplitRegistry.



6
7
8
# File 'app/models/test_track/split_registry.rb', line 6

def initialize(registry_hash)
  @registry_hash = registry_hash
end

Class Method Details

.from_remoteObject



2
3
4
# File 'app/models/test_track/split_registry.rb', line 2

def self.from_remote
  new(TestTrack::Remote::SplitRegistry.to_hash)
end

Instance Method Details

#experience_sampling_weightObject



22
23
24
# File 'app/models/test_track/split_registry.rb', line 22

def experience_sampling_weight
  registry_hash.fetch('experience_sampling_weight')
end

#include?(split_name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/test_track/split_registry.rb', line 10

def include?(split_name)
  registry_hash['splits'].key?(split_name)
end

#loaded?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/test_track/split_registry.rb', line 14

def loaded?
  registry_hash.present?
end

#split_namesObject



18
19
20
# File 'app/models/test_track/split_registry.rb', line 18

def split_names
  registry_hash['splits'].keys
end

#to_hashObject



30
31
32
33
34
# File 'app/models/test_track/split_registry.rb', line 30

def to_hash
  registry_hash && registry_hash['splits'].transform_values do |v|
    { weights: v['weights'], feature_gate: v['feature_gate'] }
  end
end

#weights_for(split_name) ⇒ Object



26
27
28
# File 'app/models/test_track/split_registry.rb', line 26

def weights_for(split_name)
  registry_hash && registry_hash['splits'][split_name] && registry_hash['splits'][split_name]['weights'].freeze
end