Class: TrailGuide::Helper::HelperProxy

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

Direct Known Subclasses

ExperimentProxy

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(key, **opts, &block) ⇒ Object Also known as: enroll



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

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

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



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

def choose!(key, **opts, &block)
  new(key).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(key, checkpoint = nil, **opts, &block) ⇒ Object



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

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

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



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

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

#new(key) ⇒ Object



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

def new(key)
  ExperimentProxy.new(context, key, participant: participant)
end

#participantObject



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

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

#render(key, **opts) ⇒ Object



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

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

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



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

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

#run(key, **opts) ⇒ Object



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

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

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



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

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