class Unleash::Strategy::GradualRolloutRandom

Public Instance Methods

is_enabled?(params = {}, _context = nil) click to toggle source

need: params

# 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
name() click to toggle source
# File lib/unleash/strategy/gradual_rollout_random.rb, line 6
def name
  'gradualRolloutRandom'
end