Sha256: 9beb4a3e2fb407d2c9e7c253dbc9919cd257f8509578bf5e49b4498839581397
Contents?: true
Size: 616 Bytes
Versions: 1
Compression:
Stored size: 616 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.active? cookie = EenyMeeny::Cookie.read(request.cookie_jar[EenyMeeny::Cookie.cookie_name(@experiment)]) return false if cookie.nil? # Not participating in experiment (@variation_id.nil? || @variation_id == cookie[:variation].id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eeny-meeny-2.0.0 | lib/eeny-meeny/routing/experiment_constraint.rb |