Class: TrailGuide::Helper::HelperProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/trail_guide/helper.rb

Direct Known Subclasses

MetricProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contextObject (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_typeObject



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

#participantObject



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