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.



68
69
70
71
# File 'lib/trail_guide/helper.rb', line 68

def initialize(context, participant: nil)
  @context = context
  @participant = participant
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



66
67
68
# File 'lib/trail_guide/helper.rb', line 66

def context
  @context
end

Instance Method Details

#choose(metric, **opts, &block) ⇒ Object Also known as: enroll



82
83
84
# File 'lib/trail_guide/helper.rb', line 82

def choose(metric, **opts, &block)
  new(metric).choose(**opts, &block)
end

#choose!(metric, **opts, &block) ⇒ Object Also known as: enroll!



77
78
79
# File 'lib/trail_guide/helper.rb', line 77

def choose!(metric, **opts, &block)
  new(metric).choose!(**opts, &block)
end

#context_typeObject



115
116
117
118
119
120
121
# File 'lib/trail_guide/helper.rb', line 115

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



107
108
109
# File 'lib/trail_guide/helper.rb', line 107

def convert(metric, checkpoint=nil, **opts, &block)
  new(metric).convert(checkpoint, **opts, &block)
end

#convert!(metric, checkpoint = nil, **opts, &block) ⇒ Object



103
104
105
# File 'lib/trail_guide/helper.rb', line 103

def convert!(metric, checkpoint=nil, **opts, &block)
  new(metric).convert!(checkpoint, **opts, &block)
end

#new(metric) ⇒ Object



73
74
75
# File 'lib/trail_guide/helper.rb', line 73

def new(metric)
  MetricProxy.new(context, metric, participant: participant)
end

#participantObject



111
112
113
# File 'lib/trail_guide/helper.rb', line 111

def participant
  @participant ||= context.send(:trailguide_participant)
end

#render(metric, **opts) ⇒ Object



99
100
101
# File 'lib/trail_guide/helper.rb', line 99

def render(metric, **opts)
  new(metric).render(**opts)
end

#render!(metric, **opts) ⇒ Object



95
96
97
# File 'lib/trail_guide/helper.rb', line 95

def render!(metric, **opts)
  new(metric).render!(**opts)
end

#run(metric, **opts) ⇒ Object



91
92
93
# File 'lib/trail_guide/helper.rb', line 91

def run(metric, **opts)
  new(metric).run(**opts)
end

#run!(metric, **opts) ⇒ Object



87
88
89
# File 'lib/trail_guide/helper.rb', line 87

def run!(metric, **opts)
  new(metric).run!(**opts)
end