Class: Unleash::Strategy::GradualRolloutRandom

Inherits:
Base
  • Object
show all
Defined in:
lib/unleash/strategy/gradual_rollout_random.rb

Instance Method Summary collapse

Instance Method Details

#is_enabled?(params = {}, _context = nil) ⇒ Boolean

need: params

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/unleash/strategy/gradual_rollout_random.rb', line 11

def is_enabled?(params = {}, _context = nil)
  return false unless params.is_a?(Hash) && params.has_key?('percentage')

  begin
    percentage = Integer(params['percentage'] || 0)
  rescue ArgumentError
    return false
  end

  (percentage >= Random.rand(1..100))
end

#nameObject



6
7
8
# File 'lib/unleash/strategy/gradual_rollout_random.rb', line 6

def name
  'gradualRolloutRandom'
end