Module: AbingoSugar
- Defined in:
- lib/abingo_sugar.rb
Overview
This module exists entirely to save finger strain for programmers. It is designed to be included in your ApplicationController.
See abingo.rb for descriptions of what these do.
Instance Method Summary collapse
- #ab_test(abingo, test_name, alternatives = nil, options = {}) ⇒ Object
-
#abingo_mark_human(abingo) ⇒ Object
Mark the user as a human.
- #bingo!(abingo, test_name, options = {}) ⇒ Object
Instance Method Details
#ab_test(abingo, test_name, alternatives = nil, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/abingo_sugar.rb', line 8 def ab_test(abingo, test_name, alternatives = nil, = {}) if (Abingo.[:enable_specification] && !params[test_name].nil?) choice = params[test_name] elsif (Abingo.[:enable_override_in_session] && !session[test_name].nil?) choice = session[test_name] elsif (alternatives.nil?) choice = abingo.flip(test_name) else choice = abingo.test(test_name, alternatives, ) end if block_given? yield(choice) else choice end end |
#abingo_mark_human(abingo) ⇒ Object
Mark the user as a human.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/abingo_sugar.rb', line 31 def abingo_mark_human(abingo) textual_result = "1" begin a = params[:a].to_i b = params[:b].to_i c = params[:c].to_i if (request.method == :post && (a + b == c)) abingo.human! else textual_result = "0" end rescue #If a bot doesn't pass a, b, or c, to_i will fail. This scarfs up the exception, to save it from polluting our logs. textual_result = "0" end render :text => textual_result, :layout => false #Not actually used by browser end |
#bingo!(abingo, test_name, options = {}) ⇒ Object
26 27 28 |
# File 'lib/abingo_sugar.rb', line 26 def bingo!(abingo, test_name, = {}) abingo.bingo!(test_name, ) end |