Class: Gitlab::Experiment::Rollout::Base
- Inherits:
-
Object
- Object
- Gitlab::Experiment::Rollout::Base
- Defined in:
- lib/gitlab/experiment/rollout.rb
Direct Known Subclasses
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
-
#cache_control_enabled? ⇒ Boolean
Returns true when this rollout caches ‘:control` assignments.
- #enabled? ⇒ Boolean
-
#initialize(experiment, options = {}) ⇒ Base
constructor
A new instance of Base.
- #resolve ⇒ Object
Constructor Details
#initialize(experiment, options = {}) ⇒ Base
Returns a new instance of Base.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitlab/experiment/rollout.rb', line 29 def initialize(experiment, = {}) raise ArgumentError, 'you must provide an experiment instance' unless experiment.class <= Gitlab::Experiment @experiment = experiment @options = return if !.key?(:cache_control) || [:cache_control] == true Configuration.deprecated( :cache_control, "setting `cache_control` to a non-true value on a rollout is deprecated and " \ "will be removed in version 2.0. Control variants will always be cached.", version: '1.4' ) end |
Instance Attribute Details
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
25 26 27 |
# File 'lib/gitlab/experiment/rollout.rb', line 25 def experiment @experiment end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/gitlab/experiment/rollout.rb', line 25 def @options end |
Instance Method Details
#cache_control_enabled? ⇒ Boolean
Returns true when this rollout caches ‘:control` assignments. Per-rollout `cache_control:` option takes precedence over the global default.
62 63 64 |
# File 'lib/gitlab/experiment/rollout.rb', line 62 def cache_control_enabled? .fetch(:cache_control, Configuration.cache_control) end |
#enabled? ⇒ Boolean
45 46 47 |
# File 'lib/gitlab/experiment/rollout.rb', line 45 def enabled? true end |
#resolve ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gitlab/experiment/rollout.rb', line 49 def resolve validate! # allow the rollout strategy to validate itself assignment = execute_assignment # Cache control assignments unless explicitly opted out. The per-rollout `cache_control:` # option takes precedence over the global `Configuration.cache_control` default. return assignment if cache_control_enabled? assignment == :control ? nil : assignment end |