This came up recently on some work on gitlab, where we're using scientist for some of our experimentation work.
Ultimately I was extracting some of the base experiment behavior into a module, and realize that in doing this, it sets the default @experiment_klass to a module, and that breaks when trying to use the science method. So basically it doesn't seem like the included callback should be setting the default class if it's a module.
The only way to get around this is to:
module MyModule
Scientist::Experiment.send(:append_features, self)
extend Scientist::Experiment::RaiseOnMismatch
#... implementation
end
Which doesn't really seem right. I know we can do Scientist::Experiment.set_default(nil), but that then has load order implications and so we just don't want the behavior in general and feel like we're trying to work around a convenience that's actually somewhat hard to work around.
Coverage remained the same at 99.103% when pulling a6222a6158e25dc5d7baa00d3cbc1e92b96c0e3c on jejacks0n:no-set-default-for-module into 15ca554bbb83c73c92e00ba478dab86c7805304c on github:master.
This came up recently on some work on gitlab, where we're using scientist for some of our experimentation work.
Ultimately I was extracting some of the base experiment behavior into a module, and realize that in doing this, it sets the default
@experiment_klass
to a module, and that breaks when trying to use thescience
method. So basically it doesn't seem like theincluded
callback should be setting the default class if it's a module.The only way to get around this is to:
Which doesn't really seem right. I know we can do
Scientist::Experiment.set_default(nil)
, but that then has load order implications and so we just don't want the behavior in general and feel like we're trying to work around a convenience that's actually somewhat hard to work around.Thoughts?