Module: Vanity::Helpers
- Defined in:
- lib/vanity/helpers.rb
Overview
Helper methods available on Object.
Instance Method Summary collapse
-
#ab_test(name, &block) ⇒ Object
This method returns one of the alternative values in the named A/B test.
-
#track!(name, count = 1) ⇒ Object
Tracks an action associated with a metric.
Instance Method Details
#ab_test(name, &block) ⇒ Object
This method returns one of the alternative values in the named A/B test.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vanity/helpers.rb', line 36 def ab_test(name, &block) if Vanity.playground.using_js? @_vanity_experiments ||= {} @_vanity_experiments[name] ||= Vanity.playground.experiment(name).choose value = @_vanity_experiments[name].value else value = Vanity.playground.experiment(name).choose.value end if block content = capture(value, &block) block_called_from_erb?(block) ? concat(content) : content else value end end |
#track!(name, count = 1) ⇒ Object
Tracks an action associated with a metric.
58 59 60 |
# File 'lib/vanity/helpers.rb', line 58 def track!(name, count = 1) Vanity.playground.track! name, count end |