Class: TrailGuide::Experiments::Participant
- Inherits:
-
Object
- Object
- TrailGuide::Experiments::Participant
show all
- Defined in:
- lib/trail_guide/experiments/participant.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(experiment, participant) ⇒ Participant
Returns a new instance of Participant.
7
8
9
10
|
# File 'lib/trail_guide/experiments/participant.rb', line 7
def initialize(experiment, participant)
@experiment = experiment
@participant = participant
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
46
47
48
49
|
# File 'lib/trail_guide/experiments/participant.rb', line 46
def method_missing(meth, *args, &block)
return participant.send(meth, *args, &block) if participant.respond_to?(meth, true)
super
end
|
Instance Attribute Details
#experiment ⇒ Object
Returns the value of attribute experiment.
4
5
6
|
# File 'lib/trail_guide/experiments/participant.rb', line 4
def experiment
@experiment
end
|
#participant ⇒ Object
Returns the value of attribute participant.
4
5
6
|
# File 'lib/trail_guide/experiments/participant.rb', line 4
def participant
@participant
end
|
Instance Method Details
#converted!(variant, checkpoint, reset: false) ⇒ Object
29
30
31
32
33
|
# File 'lib/trail_guide/experiments/participant.rb', line 29
def converted!(variant, checkpoint, reset: false)
@converted ||= {}
@converted[checkpoint || :converted] ||= true
participant.converted!(variant, checkpoint, reset: reset)
end
|
#converted?(checkpoint = nil) ⇒ Boolean
22
23
24
25
26
27
|
# File 'lib/trail_guide/experiments/participant.rb', line 22
def converted?(checkpoint=nil)
@converted ||= {}
converted_key = checkpoint || :converted
@converted[converted_key] = participant.converted?(experiment, checkpoint) unless @converted.key?(converted_key)
@converted[converted_key]
end
|
#exit! ⇒ Object
39
40
41
42
43
44
|
# File 'lib/trail_guide/experiments/participant.rb', line 39
def exit!
@participating = nil
@converted = nil
@variant = nil
participant.exit!(experiment)
end
|
#participating!(variant) ⇒ Object
16
17
18
19
20
|
# File 'lib/trail_guide/experiments/participant.rb', line 16
def participating!(variant)
@participating = true
@variant = variant
participant.participating!(variant) if experiment.configuration.sticky_assignment?
end
|
#participating? ⇒ Boolean
12
13
14
|
# File 'lib/trail_guide/experiments/participant.rb', line 12
def participating?
@participating ||= variant.present?
end
|
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
51
52
53
|
# File 'lib/trail_guide/experiments/participant.rb', line 51
def respond_to_missing?(meth, include_private=false)
participant.respond_to?(meth, include_private)
end
|
#variant ⇒ Object
35
36
37
|
# File 'lib/trail_guide/experiments/participant.rb', line 35
def variant
@variant ||= participant.variant(experiment)
end
|