Module: Bandit::ViewConcerns::InstanceMethods
- Defined in:
- lib/bandit/extensions/view_concerns.rb
Instance Method Summary collapse
-
#bandit_choose(exp) ⇒ Object
FIXME: deprecated (for compatibility with bandit gem & older bandido versions) ——————————————————————————.
-
#bandit_session_choose(exp) ⇒ Object
stick to one alternative for the entire browser session.
-
#bandit_simple_choose(exp) ⇒ Object
always choose something new and increase the participant count.
-
#bandit_sticky_choose(exp) ⇒ Object
stick to one alternative until user deletes cookies or changes browser.
Instance Method Details
#bandit_choose(exp) ⇒ Object
FIXME: deprecated (for compatibility with bandit gem & older bandido versions)
42 43 44 |
# File 'lib/bandit/extensions/view_concerns.rb', line 42 def bandit_choose(exp) bandit_session_choose(exp) end |
#bandit_session_choose(exp) ⇒ Object
stick to one alternative for the entire browser session
17 18 19 20 21 22 23 |
# File 'lib/bandit/extensions/view_concerns.rb', line 17 def bandit_session_choose(exp) name = "bandit_#{exp}".intern # choose url param with preference value = params[name].nil? ? .signed[name] : params[name] # choose with default, and set cookie .signed[name] = Bandit.get_experiment(exp).choose(value) end |
#bandit_simple_choose(exp) ⇒ Object
always choose something new and increase the participant count
12 13 14 |
# File 'lib/bandit/extensions/view_concerns.rb', line 12 def bandit_simple_choose(exp) Bandit.get_experiment(exp).choose(nil) end |
#bandit_sticky_choose(exp) ⇒ Object
stick to one alternative until user deletes cookies or changes browser
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bandit/extensions/view_concerns.rb', line 26 def bandit_sticky_choose(exp) name = "bandit_#{exp}".intern # choose url param with preference value = params[name].nil? ? .signed[name] : params[name] # sticky choice may outlast a given alternative alternative = if Bandit.get_experiment(exp).alternatives.include?(value) value else Bandit.get_experiment(exp).choose(value) end # re-set cookie .permanent.signed[name] = alternative end |