Class: Unleash::Strategy::UserWithId

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

Constant Summary collapse

PARAM =
'userIds'.freeze

Instance Method Summary collapse

Instance Method Details

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

requires: params, context.user_id,

Returns:

  • (Boolean)


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

def is_enabled?(params = {}, context = nil)
  return false unless params.is_a?(Hash) && params.has_key?(PARAM)
  return false unless params.fetch(PARAM, nil).is_a? String
  return false unless context.instance_of?(Unleash::Context)

  params[PARAM].split(",").map(&:strip).include?(context.user_id)
end

#nameObject



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

def name
  'userWithId'
end