Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created February 14, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlafeldt/d4c7f03fd9521aa45a562e2bee8f0f41 to your computer and use it in GitHub Desktop.
Save mlafeldt/d4c7f03fd9521aa45a562e2bee8f0f41 to your computer and use it in GitHub Desktop.
Scientist example
require "scientist"
class MyExperiment
include Scientist::Experiment
attr_accessor :name
def initialize(name)
@name = name
end
def enabled?
true
end
def publish(result)
puts result.control.cleaned_value
end
def raise_on_mismatches
true
end
end
module Scientist::Experiment
def self.new(name)
MyExperiment.new(name: name)
end
end
class MyWidget
include Scientist
def last_name(user)
science "widget-permissions" do |experiment|
experiment.use { "Lafeldt" }
experiment.try { "Loveheld" }
end
end
end
MyWidget.new.last_name "Mathias"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment