Class: Absurdity::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- Absurdity::Railtie
- Defined in:
- lib/absurdity/railtie.rb
Class Method Summary collapse
- .complete(experiment_slug, variant_slug) ⇒ Object
- .load_experiments ⇒ Object
- .new_experiment(experiment_slug, metrics_list, variants_list = nil) ⇒ Object
Class Method Details
.complete(experiment_slug, variant_slug) ⇒ Object
26 27 28 29 |
# File 'lib/absurdity/railtie.rb', line 26 def self.complete(experiment_slug, variant_slug) experiment = Experiment.find(experiment_slug) experiment.complete(variant_slug) end |
.load_experiments ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/absurdity/railtie.rb', line 8 def self.load_experiments experiments_to_create = YAML.load_file("absurdity/experiments.yml")[:experiments] experiments_to_create.each do |experiment_slug, values| metrics_list = values[:metrics] variants_list = values[:variants] experiment = new_experiment(experiment_slug, metrics_list, variants_list) complete(experiment_slug, values[:completed]) if values[:completed] && !experiment.completed end end |
.new_experiment(experiment_slug, metrics_list, variants_list = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/absurdity/railtie.rb', line 18 def self.new_experiment(experiment_slug, metrics_list, variants_list=nil) begin experiment = Experiment.find(experiment_slug) rescue Experiment::NotFoundError Experiment.create(experiment_slug, metrics_list, variants_list) end end |