Class: Gitlab::Experiment::Rollout::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/experiment/rollout.rb

Direct Known Subclasses

Percent, Random, RoundRobin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(experiment, options = {}) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


29
30
31
32
33
34
# File 'lib/gitlab/experiment/rollout.rb', line 29

def initialize(experiment, options = {})
  raise ArgumentError, 'you must provide an experiment instance' unless experiment.class <= Gitlab::Experiment

  @experiment = experiment
  @options = options
end

Instance Attribute Details

#experimentObject (readonly)

Returns the value of attribute experiment.



25
26
27
# File 'lib/gitlab/experiment/rollout.rb', line 25

def experiment
  @experiment
end

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/gitlab/experiment/rollout.rb', line 25

def options
  @options
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitlab/experiment/rollout.rb', line 36

def enabled?
  true
end

#resolveObject



40
41
42
43
44
45
# File 'lib/gitlab/experiment/rollout.rb', line 40

def resolve
  validate! # allow the rollout strategy to validate itself

  assignment = execute_assignment
  assignment == :control ? nil : assignment # avoid caching control by returning nil
end