Class: TestTrack::SplitRegistry
- Inherits:
-
Object
- Object
- TestTrack::SplitRegistry
- Defined in:
- app/models/test_track/split_registry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #experience_sampling_weight ⇒ Object
- #include?(split_name) ⇒ Boolean
-
#initialize(registry_hash) ⇒ SplitRegistry
constructor
A new instance of SplitRegistry.
- #loaded? ⇒ Boolean
- #split_names ⇒ Object
- #to_hash ⇒ Object
- #weights_for(split_name) ⇒ Object
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_remote ⇒ Object
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_weight ⇒ Object
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
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
14 15 16 |
# File 'app/models/test_track/split_registry.rb', line 14 def loaded? registry_hash.present? end |
#split_names ⇒ Object
18 19 20 |
# File 'app/models/test_track/split_registry.rb', line 18 def split_names registry_hash['splits'].keys end |
#to_hash ⇒ Object
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 |