Class: Unleash::Strategy::GradualRolloutUserId

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

Instance Method Summary collapse

Instance Method Details

#is_enabled?(params = {}, context = nil, _constraints = []) ⇒ Boolean

need: params, params, context.user_id,

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'lib/unleash/strategy/gradual_rollout_userid.rb', line 11

def is_enabled?(params = {}, context = nil, _constraints = [])
  return false unless params.is_a?(Hash) && params.has_key?('percentage')
  return false unless context.instance_of?(Unleash::Context)
  return false if context.user_id.nil? || context.user_id.empty?

  percentage = Integer(params['percentage'] || 0)
  (percentage.positive? && Util.get_normalized_number(context.user_id, params['groupId'] || "") <= percentage)
end

#nameObject



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

def name
  'gradualRolloutUserId'
end