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
44
45
46
47
|
# File 'lib/trail_guide/experiments/participant.rb', line 44
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 = nil, reset: false) ⇒ Object
28
29
30
31
32
|
# File 'lib/trail_guide/experiments/participant.rb', line 28
def converted!(variant, checkpoint=nil, 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
|
# File 'lib/trail_guide/experiments/participant.rb', line 38
def exit!
@converted = nil
@variant = nil
participant.exit!(experiment)
end
|
#participating!(variant) ⇒ Object
16
17
18
19
|
# File 'lib/trail_guide/experiments/participant.rb', line 16
def participating!(variant)
@variant = variant
participant.participating!(variant) if experiment.configuration.sticky_assignment?
end
|
#participating?(include_control = true) ⇒ Boolean
12
13
14
|
# File 'lib/trail_guide/experiments/participant.rb', line 12
def participating?(include_control=true)
participant.participating?(experiment, include_control)
end
|
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
49
50
51
|
# File 'lib/trail_guide/experiments/participant.rb', line 49
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
|