module SplitCat::Helpers

Public Instance Methods

split_cat_goal( name, goal, token ) click to toggle source

split_cat_goal

# File lib/split_cat/helpers.rb, line 14
def split_cat_goal( name, goal, token )
  unless experiment = Experiment.factory( name )
    Rails.logger.error( "Experiment.goal failed to find experiment: #{name}" )
    return false
  end

  return experiment.record_goal( goal, token )
end
split_cat_hypothesis( name, token ) click to toggle source

split_cat_hypothesis

# File lib/split_cat/helpers.rb, line 26
def split_cat_hypothesis( name, token )
  unless experiment = Experiment.factory( name )
    Rails.logger.error( "Experiment.hypothesis failed to find experiment: #{name}" )
    return nil
  end

  h = experiment.get_hypothesis( token )
  return h ? h.name.to_sym : nil
end
split_cat_scope( root, name, token, hypothesis = nil ) click to toggle source

split_cat_scope

# File lib/split_cat/helpers.rb, line 39
def split_cat_scope( root, name, token, hypothesis = nil )
  hypothesis = split_cat_hypothesis( name, token ) unless hypothesis
  return root + '_' + hypothesis.to_s
end
split_cat_token( value = nil ) click to toggle source

split_cat_token

# File lib/split_cat/helpers.rb, line 7
def split_cat_token( value = nil )
  SplitCat::Subject.create( :token => value ).token
end