class AbPanel::Config

Public Class Methods

new() click to toggle source
# File lib/ab_panel/config.rb, line 5
def initialize
  OpenStruct.new settings
end

Public Instance Methods

experiments() click to toggle source
# File lib/ab_panel/config.rb, line 9
def experiments
  return {} if !settings
  settings.keys.map(&:to_sym)
end
scenarios(experiment) click to toggle source
# File lib/ab_panel/config.rb, line 14
def scenarios(experiment)
  raise ArgumentError.new( "Fatal: Experiment config not found for #{experiment}" ) unless experiments.include? experiment.to_sym
  ( settings[experiment.to_sym].keys.map(&:to_sym)).uniq
end
settings() click to toggle source
# File lib/ab_panel/config.rb, line 24
def settings
  return @settings if defined?(@settings)
  results = YAML.load(ERB.new(File.read(File.join(Rails.root, 'config', 'ab_panel.yml'))).result)
  @settings = results ? results.symbolize_keys : nil
end
weights(experiment) click to toggle source
# File lib/ab_panel/config.rb, line 19
def weights(experiment)
  raise ArgumentError.new( "Fatal: Experiment config not found for #{experiment}" ) unless experiments.include? experiment.to_sym
  settings[experiment.to_sym].map { |s| s[1] }
end