Class: Split::ExperimentCatalog

Inherits:
Object
  • Object
show all
Defined in:
lib/split/experiment_catalog.rb

Class Method Summary collapse

Class Method Details

.allObject



3
4
5
# File 'lib/split/experiment_catalog.rb', line 3

def self.all
  Split.redis.smembers(:experiments).map {|e| find(e)}
end

.all_active_firstObject

Return experiments without a winner (considered “active”) first



8
9
10
# File 'lib/split/experiment_catalog.rb', line 8

def self.all_active_first
  all.partition{|e| not e.winner}.map{|es| es.sort_by(&:name)}.flatten
end

.find(name) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/split/experiment_catalog.rb', line 12

def self.find(name)
  if Split.redis.exists(name)
    obj = Experiment.new name
    obj.load_from_redis
  else
    obj = nil
  end
  obj
end

.find_or_create(label, *alternatives) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/split/experiment_catalog.rb', line 22

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