Sha256: 706394a81476965e867549ea3fd9d29e8a8648a481c23bafccf3c949d14b770b

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

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

  def initialize(registry_hash)
    @registry_hash = registry_hash
  end

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

  def loaded?
    registry_hash.present?
  end

  def split_names
    registry_hash['splits'].keys
  end

  def experience_sampling_weight
    registry_hash.fetch('experience_sampling_weight')
  end

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

  def to_v1_hash
    registry_hash && registry_hash['splits'].each_with_object({}) do |(k, v), result|
      result[k] = v['weights']
    end
  end

  private

  attr_reader :registry_hash
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_track_rails_client-4.0.0.alpha32 app/models/test_track/split_registry.rb
test_track_rails_client-4.0.0.alpha31 app/models/test_track/split_registry.rb
test_track_rails_client-4.0.0.alpha30 app/models/test_track/split_registry.rb