Permalink
Browse files

Adding new feature to A/Bingo: specify alternatives in session. Usefu…

…l for coercing people to a particular alternative for CS purposes.
  • Loading branch information...
1 parent 8140ef5 commit 42a5a3f80c2da805a608077b328822b482400d0a Patrick McKenzie committed May 19, 2010
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/abingo.rb
  2. +2 −0 lib/abingo_sugar.rb
  3. +4 −0 lib/abingo_view_helper.rb
View
@@ -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.
View
@@ -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
@@ -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
@@ -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

0 comments on commit 42a5a3f

Please sign in to comment.