class Laboratory::User

Attributes

id[R]

Public Class Methods

new(id:) click to toggle source
# File lib/laboratory/user.rb, line 5
def initialize(id:)
  @id = id
end

Public Instance Methods

experiments() click to toggle source
# 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) click to toggle source
# File lib/laboratory/user.rb, line 17
def variant_for_experiment(experiment)
  experiment.variants.find do |variant|
    variant.participant_ids.include?(id)
  end
end