Slide 43
Slide 43 text
class ABExperimentBuilder < Module
def initialize(name:, test_cell:, control_cell: 'Control')
const_set(:NAME, name)
const_set(:CONTROL_CELL, control_cell)
const_set(:TEST_CELL, test_cell)
attr_reader :api, :client
define_method(:initialize) do |client|
@client = client
@api = StitchFix::Experiments::API.new(
experiment_name: self.class.const_get(:NAME),
test_subject: client
)
end
end
module ClassMethods
def define!
klass = self
StitchFix::Experiments::API.define_experiment do
name klass.const_get(:NAME)
treatment klass.const_get(:CONTROL_CELL), control: true
treatment klass.const_get(:TEST_CELL)
allocation Time.now..6.months.from_now
live true
owner Client.first
end
end
end
def included(base)
base.extend ClassMethods
end
end