Sha256: 9f59fb79cb588a24f5b6512cde341aff15e8f70698ae125d4324440b64c0e818
Contents?: true
Size: 681 Bytes
Versions: 8
Compression:
Stored size: 681 Bytes
Contents
require 'eeny-meeny/models/cookie' require 'eeny-meeny/models/experiment' module EenyMeeny class ExperimentConstraint def initialize(experiment_id, variation_id: nil) @experiment = EenyMeeny::Experiment.find_by_id(experiment_id) @variation_id = variation_id end def matches?(request) return false unless !@experiment.nil? && @experiment.active? participant_variation_id = EenyMeeny::Cookie.read(request.cookie_jar[EenyMeeny::Cookie.cookie_name(@experiment)]) return false if participant_variation_id.nil? # Not participating in experiment (@variation_id.nil? || @variation_id.to_s == participant_variation_id) end end end
Version data entries
8 entries across 8 versions & 1 rubygems