lib/split/user.rb in split-4.0.1 vs lib/split/user.rb in split-4.0.2

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'forwardable' +require "forwardable" module Split class User extend Forwardable def_delegators :@user, :keys, :[], :[]=, :delete @@ -24,14 +24,14 @@ end @cleaned_up = true end def max_experiments_reached?(experiment_key) - if Split.configuration.allow_multiple_experiments == 'control' + if Split.configuration.allow_multiple_experiments == "control" experiments = active_experiments experiment_key_without_version = key_without_version(experiment_key) - count_control = experiments.count {|k, v| k == experiment_key_without_version || v == 'control'} + count_control = experiments.count { |k, v| k == experiment_key_without_version || v == "control" } experiments.size > count_control else !Split.configuration.allow_multiple_experiments && keys_without_experiment(user.keys, experiment_key).length > 0 end @@ -63,19 +63,18 @@ nil end end private + def keys_without_experiment(keys, experiment_key) + keys.reject { |k| k.match(Regexp.new("^#{experiment_key}(:finished)?$")) } + end - def keys_without_experiment(keys, experiment_key) - keys.reject { |k| k.match(Regexp.new("^#{experiment_key}(:finished)?$")) } - end + def keys_without_finished(keys) + keys.reject { |k| k.include?(":finished") } + end - def keys_without_finished(keys) - keys.reject { |k| k.include?(":finished") } - end - - def key_without_version(key) - key.split(/\:\d(?!\:)/)[0] - end + def key_without_version(key) + key.split(/\:\d(?!\:)/)[0] + end end end