Module: Sinatra::AbingoHelper

Defined in:
lib/sinmetrics/abingo.rb

Instance Method Summary collapse

Instance Method Details

#ab_test(test_name, alternatives = nil, options = {}) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/sinmetrics/abingo.rb', line 227

def ab_test(test_name, alternatives = nil, options = {})
  if (abingo.enable_specification && !params[test_name].blank?)
    choice = params[test_name]
  elsif (alternatives.nil?)
    choice = abingo.flip(test_name)
  else
    choice = abingo.test(test_name, alternatives, options)
  end

  if block_given?
    yield(choice)
  else
    choice
  end
end

#abingoObject Also known as: ab



223
224
225
# File 'lib/sinmetrics/abingo.rb', line 223

def abingo
  env['abingo.helper'] ||= AbingoObject.new(self)
end