Class: TrailGuide::Helper::HelperProxy
- Inherits:
-
Object
- Object
- TrailGuide::Helper::HelperProxy
- Defined in:
- lib/trail_guide/helper/helper_proxy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #choose(key, **opts, &block) ⇒ Object (also: #enroll)
- #choose!(key, **opts, &block) ⇒ Object (also: #enroll!)
- #context_type ⇒ Object
- #convert(key, checkpoint = nil, **opts, &block) ⇒ Object
- #convert!(key, checkpoint = nil, **opts, &block) ⇒ Object
-
#initialize(context, participant: nil) ⇒ HelperProxy
constructor
A new instance of HelperProxy.
- #new(key) ⇒ Object
- #participant ⇒ Object
- #render(key, **opts) ⇒ Object
- #render!(key, **opts) ⇒ Object
- #run(key, **opts) ⇒ Object
- #run!(key, **opts) ⇒ Object
Constructor Details
#initialize(context, participant: nil) ⇒ HelperProxy
Returns a new instance of HelperProxy.
6 7 8 9 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 6 def initialize(context, participant: nil) @context = context @participant = participant end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 4 def context @context end |
Instance Method Details
#choose(key, **opts, &block) ⇒ Object Also known as: enroll
20 21 22 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 20 def choose(key, **opts, &block) new(key).choose(**opts, &block) end |
#choose!(key, **opts, &block) ⇒ Object Also known as: enroll!
15 16 17 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 15 def choose!(key, **opts, &block) new(key).choose!(**opts, &block) end |
#context_type ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 53 def context_type if context.is_a?(ActionView::Context) :template elsif context.is_a?(ActionController::Base) :controller end end |
#convert(key, checkpoint = nil, **opts, &block) ⇒ Object
45 46 47 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 45 def convert(key, checkpoint=nil, **opts, &block) new(key).convert(checkpoint, **opts, &block) end |
#convert!(key, checkpoint = nil, **opts, &block) ⇒ Object
41 42 43 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 41 def convert!(key, checkpoint=nil, **opts, &block) new(key).convert!(checkpoint, **opts, &block) end |
#new(key) ⇒ Object
11 12 13 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 11 def new(key) ExperimentProxy.new(context, key, participant: participant) end |
#participant ⇒ Object
49 50 51 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 49 def participant @participant ||= context.send(:trailguide_participant) end |
#render(key, **opts) ⇒ Object
37 38 39 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 37 def render(key, **opts) new(key).render(**opts) end |
#render!(key, **opts) ⇒ Object
33 34 35 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 33 def render!(key, **opts) new(key).render!(**opts) end |
#run(key, **opts) ⇒ Object
29 30 31 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 29 def run(key, **opts) new(key).run(**opts) end |
#run!(key, **opts) ⇒ Object
25 26 27 |
# File 'lib/trail_guide/helper/helper_proxy.rb', line 25 def run!(key, **opts) new(key).run!(**opts) end |