Module: Fabes::Helper
- Defined in:
- lib/fabes/helper.rb
Instance Method Summary collapse
Instance Method Details
#fabes(name, control, *alternatives) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fabes/helper.rb', line 3 def fabes(name, control, *alternatives) experiment = Fabes::Experiment.find_or_create(name, *([control] + alternatives)) if trackable_for experiment.name alternative = experiment.select_alternative! experiment, alternative alternative.increment_participants! alternative.update_weight else alternative = current_alternative_for experiment end alternative.payload rescue control end |
#score!(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fabes/helper.rb', line 19 def score!(name) experiment = Fabes::Experiment.find name alternative = current_alternative_for experiment if scorable? experiment.name alternative.increment_hits! alternative.update_weight mark_as_scored experiment.name end rescue #Failed scoring, do nothin' nil end |