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.
6
7
8
9
|
# File 'lib/trail_guide/experiments/participant.rb', line 6
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
45
46
47
48
|
# File 'lib/trail_guide/experiments/participant.rb', line 45
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
28
29
30
31
32
|
# File 'lib/trail_guide/experiments/participant.rb', line 28
def converted!(variant, checkpoint, reset: false)
@converted ||= {}
@converted[checkpoint || :converted] ||= true
participant.converted!(variant, checkpoint, reset: reset)
end
|
#converted?(checkpoint = nil) ⇒ Boolean
21
22
23
24
25
26
|
# File 'lib/trail_guide/experiments/participant.rb', line 21
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
38
39
40
41
42
43
|
# File 'lib/trail_guide/experiments/participant.rb', line 38
def exit!
@participating = nil
@converted = nil
@variant = nil
participant.exit!(experiment)
end
|
#participating!(variant) ⇒ Object
15
16
17
18
19
|
# File 'lib/trail_guide/experiments/participant.rb', line 15
def participating!(variant)
@participating = true
@variant = variant
participant.participating!(variant) if experiment.configuration.sticky_assignment?
end
|
#participating? ⇒ Boolean
11
12
13
|
# File 'lib/trail_guide/experiments/participant.rb', line 11
def participating?
@participating ||= variant.present?
end
|
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
50
51
52
|
# File 'lib/trail_guide/experiments/participant.rb', line 50
def respond_to_missing?(meth, include_private=false)
participant.respond_to?(meth, include_private)
end
|
#variant ⇒ Object
34
35
36
|
# File 'lib/trail_guide/experiments/participant.rb', line 34
def variant
@variant ||= participant.variant(experiment)
end
|