Skip to content

Commit

Permalink
Adding new feature to A/Bingo: specify alternatives in session. Usefu…
Browse files Browse the repository at this point in the history
…l for coercing people to a particular alternative for CS purposes.
  • Loading branch information
Patrick McKenzie committed May 19, 2010
1 parent 8140ef5 commit 42a5a3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/abingo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Abingo

#Defined options:
# :enable_specification => if true, allow params[test_name] to override the calculated value for a test.
# :enable_override_in_sesion => if true, allows session[test_name] to override the calculated value for a test.
# :expires_in => if not nil, passes expire_in to creation of per-user cache keys. Useful for Redis, to prevent expired sessions
# from running wild and consuming all of your memory.

Expand Down
2 changes: 2 additions & 0 deletions lib/abingo_sugar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module AbingoSugar
def ab_test(test_name, alternatives = nil, options = {})
if (Abingo.options[:enable_specification] && !params[test_name].blank?)
choice = params[test_name]
elsif (Abingo.options[:enable_override_in_sesion] && !session[test_name].blank?)
choice = session[test_name]
elsif (alternatives.nil?)
choice = Abingo.flip(test_name)
else
Expand Down
4 changes: 4 additions & 0 deletions lib/abingo_view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module AbingoViewHelper
def ab_test(test_name, alternatives = nil, options = {})
if (Abingo.options[:enable_specification] && !params[test_name].blank?)
choice = params[test_name]
elsif (Abingo.options[:enable_override_in_sesion] && !session[test_name].blank?)
choice = session[test_name]
elsif (alternatives.nil?)
choice = Abingo.flip(test_name)
else
Expand All @@ -21,6 +23,8 @@ def ab_test(test_name, alternatives = nil, options = {})
def ab_test(test_name, alternatives = nil, options = {}, &block)
if (Abingo.options[:enable_specification] && !params[test_name].blank?)
choice = params[test_name]
elsif (Abingo.options[:enable_override_in_sesion] && !session[test_name].blank?)
choice = session[test_name]
elsif (alternatives.nil?)
choice = Abingo.flip(test_name)
else
Expand Down

0 comments on commit 42a5a3f

Please sign in to comment.