Class: Unleash::Strategy::Organization

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

Constant Summary collapse

PARAM =
'organizationIds'.freeze

Instance Method Summary collapse

Instance Method Details

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

requires: params, context.properties.organization_id,

Returns:

  • (Boolean)


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

def is_enabled?(params = {}, context = nil)
  return false unless params.is_a?(Hash) && params.key?(PARAM)
  return false unless params.fetch(PARAM, nil).is_a? String
  return false unless context.class.name == 'Unleash::Context'
  return false unless context.properties.fetch(:organization_id, nil)

  organization_id = context.properties.fetch(:organization_id)

  params[PARAM]
    .split(',')
    .map(&:strip)
    .include?(organization_id.to_s)
end

#nameObject



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

def name
  'Organization'
end