Sha256: 831f90d31c143dfdc37d8904c1b69ea120e6d0ae3aa0c674e88c8bd211b1051b

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

require 'eeny-meeny/shared_methods'

module EenyMeeny::ExperimentHelper
  @@eeny_meeny_encryptor = nil

  def participates_in?(experiment_id, variation_id: nil)
    cookie = eeny_meeny_cookie(experiment_id)
    cookie[:variation] unless cookie.nil? || (variation_id.present? && variation_id != cookie[:variation].id)
  end

  private

  def eeny_meeny_cookie(experiment_id)
    cookie = cookies[EenyMeeny::EENY_MEENY_COOKIE_PREFIX+experiment_id.to_s+'_v'+experiment_version(experiment_id).to_s]
    if cookie
      Marshal.load(decrypt(cookie)) rescue nil
    end
  end

  include EenyMeeny::SharedMethods
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eeny-meeny-1.0.0 lib/eeny-meeny/experiment_helper.rb