Created
February 14, 2017 15:28
-
-
Save mlafeldt/d4c7f03fd9521aa45a562e2bee8f0f41 to your computer and use it in GitHub Desktop.
Scientist example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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