Sha256: 426bbc53c7e2652385ae0527aac38fecfbaa6a53d15ed4921ebd96f46be30026
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
module Split class ExperimentCatalog # Return all experiments def self.all # Call compact to prevent nil experiments from being returned -- seems to happen during gem upgrades Split.redis.smembers(:experiments).map {|e| find(e)}.compact end # Return experiments without a winner (considered "active") first def self.all_active_first all.partition{|e| not e.winner}.map{|es| es.sort_by(&:name)}.flatten end def self.find(name) if Split.redis.exists(name) obj = Experiment.new name obj.load_from_redis else obj = nil end obj end def self.find_or_create(label, *alternatives) experiment_name_with_version, goals = normalize_experiment(label) name = experiment_name_with_version.to_s.split(':')[0] exp = Experiment.new name, :alternatives => alternatives, :goals => goals exp.save exp end private def self.normalize_experiment(label) if Hash === label experiment_name = label.keys.first goals = label.values.first else experiment_name = label goals = [] end return experiment_name, goals end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
split-1.0.0 | lib/split/experiment_catalog.rb |
split-0.8.0 | lib/split/experiment_catalog.rb |
split-0.7.3 | lib/split/experiment_catalog.rb |
split-0.7.2 | lib/split/experiment_catalog.rb |