Class: Laboratory::User
- Inherits:
-
Object
- Object
- Laboratory::User
- Defined in:
- lib/laboratory/user.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #experiments ⇒ Object
-
#initialize(id:) ⇒ User
constructor
A new instance of User.
- #variant_for_experiment(experiment) ⇒ Object
Constructor Details
#initialize(id:) ⇒ User
Returns a new instance of User.
5 6 7 |
# File 'lib/laboratory/user.rb', line 5 def initialize(id:) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/laboratory/user.rb', line 3 def id @id end |
Instance Method Details
#experiments ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/laboratory/user.rb', line 9 def experiments Experiment.all.select do |experiment| experiment.variants.any? do |variant| variant.participant_ids.include?(id) end end end |
#variant_for_experiment(experiment) ⇒ Object
17 18 19 20 21 |
# File 'lib/laboratory/user.rb', line 17 def variant_for_experiment(experiment) experiment.variants.find do |variant| variant.participant_ids.include?(id) end end |