Class: TrailGuide::Helper::HelperProxy
- Inherits:
-
Object
- Object
- TrailGuide::Helper::HelperProxy
- Defined in:
- lib/trail_guide/helper.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #choose!(metric, **opts, &block) ⇒ Object
- #context_type ⇒ Object
- #convert!(metric, checkpoint = nil, **opts, &block) ⇒ Object
-
#initialize(context, participant: nil) ⇒ HelperProxy
constructor
A new instance of HelperProxy.
- #new(metric) ⇒ Object
- #participant ⇒ Object
- #render!(metric, **opts) ⇒ Object
- #run!(metric, **opts) ⇒ Object
Constructor Details
#initialize(context, participant: nil) ⇒ HelperProxy
Returns a new instance of HelperProxy.
12 13 14 15 |
# File 'lib/trail_guide/helper.rb', line 12 def initialize(context, participant: nil) @context = context @participant = participant end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/trail_guide/helper.rb', line 10 def context @context end |
Instance Method Details
#choose!(metric, **opts, &block) ⇒ Object
21 22 23 |
# File 'lib/trail_guide/helper.rb', line 21 def choose!(metric, **opts, &block) new(metric).choose!(**opts, &block) end |
#context_type ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/trail_guide/helper.rb', line 41 def context_type if context.is_a?(ActionView::Context) :template elsif context.is_a?(ActionController::Base) :controller end end |
#convert!(metric, checkpoint = nil, **opts, &block) ⇒ Object
33 34 35 |
# File 'lib/trail_guide/helper.rb', line 33 def convert!(metric, checkpoint=nil, **opts, &block) new(metric).convert!(checkpoint, **opts, &block) end |
#new(metric) ⇒ Object
17 18 19 |
# File 'lib/trail_guide/helper.rb', line 17 def new(metric) MetricProxy.new(context, metric, participant: participant) end |
#participant ⇒ Object
37 38 39 |
# File 'lib/trail_guide/helper.rb', line 37 def participant @participant ||= TrailGuide::Participant.new(context) end |
#render!(metric, **opts) ⇒ Object
29 30 31 |
# File 'lib/trail_guide/helper.rb', line 29 def render!(metric, **opts) new(metric).render!(**opts) end |
#run!(metric, **opts) ⇒ Object
25 26 27 |
# File 'lib/trail_guide/helper.rb', line 25 def run!(metric, **opts) new(metric).run!(**opts) end |