class SplitCat::Config

Attributes

experiments[R]

Public Class Methods

new() click to toggle source
# File lib/split_cat/config.rb, line 11
def initialize
  @cookie_expiration = 10.years
  @experiments = HashWithIndifferentAccess.new
  @name = nil
end

Public Instance Methods

experiment( name, description = nil ) { |self| ... } click to toggle source
# File lib/split_cat/config.rb, line 17
def experiment( name, description = nil )
  @name =  name.to_sym
  @experiments[ @name ] = {
      :experiment => {
          :name => name,
          :description => description
      },
      :goals => [],
      :hypotheses => []
  }

  yield self
end
goal( name, description = nil ) click to toggle source
# File lib/split_cat/config.rb, line 35
def goal( name, description = nil )
  @experiments[ @name ][ :goals ] << { :name => name, :description => description }
end
hypothesis( name, weight, description = nil ) click to toggle source
# File lib/split_cat/config.rb, line 31
def hypothesis( name, weight, description = nil )
  @experiments[ @name ][ :hypotheses ] << { :name => name, :weight => weight, :description => description }
end
template( name ) click to toggle source
# File lib/split_cat/config.rb, line 39
def template( name )
  return nil unless data = @experiments[ name ]

  experiment = Experiment.new( data[ :experiment ] )
  data[ :hypotheses ].each { |h| experiment.hypotheses << Hypothesis.new( h ) }
  data[ :goals ].each { |g| experiment.goals << Goal.new( g ) }

  return experiment
end