Module: SplitCat::Helpers
- Defined in:
- lib/split_cat/helpers.rb
Instance Method Summary collapse
-
#set_split_cat_cookie(options = {}) ⇒ Object
#set_split_cat_cookie.
-
#split_cat_goal(name, goal, token) ⇒ Object
#split_cat_goal.
-
#split_cat_hypothesis(name, token) ⇒ Object
#split_cat_hypothesis.
-
#split_cat_scope(root, name, token, hypothesis = nil) ⇒ Object
#split_cat_scope.
-
#split_cat_token(value = nil) ⇒ Object
#split_cat_token.
Instance Method Details
#set_split_cat_cookie(options = {}) ⇒ Object
#set_split_cat_cookie
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/split_cat/helpers.rb', line 47 def ( = {} ) @split_cat_token = [ :split_cat_token ] # Create a Subject for the cookie token, if it doesn't exist if @split_cat_token && !Subject.where( :token => @split_cat_token ).first split_cat_token( @split_cat_token ) end if [ :force ] || !@split_cat_token expires = SplitCat.config..from_now @split_cat_token = split_cat_token [ :split_cat_token ] = { :value => @split_cat_token, :expires => expires } end return @split_cat_token end |
#split_cat_goal(name, goal, token) ⇒ Object
#split_cat_goal
14 15 16 17 18 19 20 21 |
# 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) ⇒ Object
#split_cat_hypothesis
26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
#split_cat_scope
39 40 41 42 |
# 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 |