Class: Gitlab::Experiment::Rollout::Base
- Inherits:
-
Object
- Object
- Gitlab::Experiment::Rollout::Base
- Defined in:
- lib/gitlab/experiment/rollout.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_OPTIONS =
{ include_control: false }.freeze
Instance Attribute Summary collapse
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #for(experiment) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #resolve ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
25 26 27 |
# File 'lib/gitlab/experiment/rollout.rb', line 25 def initialize( = {}) @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
21 22 23 |
# File 'lib/gitlab/experiment/rollout.rb', line 21 def experiment @experiment end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/gitlab/experiment/rollout.rb', line 21 def @options end |
Instance Method Details
#enabled? ⇒ Boolean
37 38 39 40 41 |
# File 'lib/gitlab/experiment/rollout.rb', line 37 def enabled? require_experiment(__method__) true end |
#for(experiment) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/gitlab/experiment/rollout.rb', line 29 def for(experiment) raise ArgumentError, 'you must provide an experiment instance' unless experiment.class <= Gitlab::Experiment @experiment = experiment self end |
#resolve ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gitlab/experiment/rollout.rb', line 43 def resolve require_experiment(__method__) return nil if @experiment.respond_to?(:experiment_group?) && !@experiment.experiment_group? validate! # allow the rollout strategy to validate itself assignment = execute_assigment assignment == :control ? nil : assignment # avoid caching control end |