Sha256: c935e87bc20a0217ff6401a5bb9fa7dddc53a628dc50c132c875a2324c6a4009

Contents?: true

Size: 448 Bytes

Versions: 8

Compression:

Stored size: 448 Bytes

Contents

module Laboratory
  class User
    attr_reader :id

    def initialize(id:)
      @id = id
    end

    def experiments
      Experiment.all.select do |experiment|
        experiment.variants.any? do |variant|
          variant.participant_ids.include?(id)
        end
      end
    end

    def variant_for_experiment(experiment)
      experiment.variants.find do |variant|
        variant.participant_ids.include?(id)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
laboratory-0.1.7 lib/laboratory/user.rb
laboratory-0.1.6 lib/laboratory/user.rb
laboratory-0.1.5 lib/laboratory/user.rb
laboratory-0.1.4 lib/laboratory/user.rb
laboratory-0.1.3 lib/laboratory/user.rb
laboratory-0.1.2 lib/laboratory/user.rb
laboratory-0.1.1 lib/laboratory/user.rb
laboratory-0.1.0 lib/laboratory/user.rb