Class: Gitlab::Experimentation::Experiment
- Inherits:
-
Object
- Object
- Gitlab::Experimentation::Experiment
- Defined in:
- lib/gitlab/experimentation/experiment.rb
Constant Summary collapse
- FEATURE_FLAG_SUFFIX =
"_experiment_percentage"
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#rollout_strategy ⇒ Object
readonly
Returns the value of attribute rollout_strategy.
-
#tracking_category ⇒ Object
readonly
Returns the value of attribute tracking_category.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #enabled_for_index?(index) ⇒ Boolean
-
#initialize(key, **params) ⇒ Experiment
constructor
A new instance of Experiment.
Constructor Details
#initialize(key, **params) ⇒ Experiment
Returns a new instance of Experiment.
10 11 12 13 14 |
# File 'lib/gitlab/experimentation/experiment.rb', line 10 def initialize(key, **params) @key = key @tracking_category = params[:tracking_category] @rollout_strategy = params[:rollout_strategy] || :cookie end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/gitlab/experimentation/experiment.rb', line 8 def key @key end |
#rollout_strategy ⇒ Object (readonly)
Returns the value of attribute rollout_strategy.
8 9 10 |
# File 'lib/gitlab/experimentation/experiment.rb', line 8 def rollout_strategy @rollout_strategy end |
#tracking_category ⇒ Object (readonly)
Returns the value of attribute tracking_category.
8 9 10 |
# File 'lib/gitlab/experimentation/experiment.rb', line 8 def tracking_category @tracking_category end |
Instance Method Details
#active? ⇒ Boolean
16 17 18 19 20 21 22 |
# File 'lib/gitlab/experimentation/experiment.rb', line 16 def active? # TODO: just touch a feature flag # Temporary change, we will change `experiment_percentage` in future to `Feature.enabled? Feature.enabled?(feature_flag_name, type: :experiment) ::Gitlab.com? && experiment_percentage > 0 end |
#enabled_for_index?(index) ⇒ Boolean
24 25 26 27 28 |
# File 'lib/gitlab/experimentation/experiment.rb', line 24 def enabled_for_index?(index) return false if index.blank? index <= experiment_percentage end |