Class: PrxAuth::ScopeList

Inherits:
Object
  • Object
show all
Defined in:
lib/prx_auth/scope_list.rb

Constant Summary collapse

SCOPE_SEPARATOR =
' '
NAMESPACE_SEPARATOR =
':'
NO_NAMESPACE =
:_

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ ScopeList

Returns a new instance of ScopeList.



7
8
9
# File 'lib/prx_auth/scope_list.rb', line 7

def initialize(list)
  @string = list
end

Instance Method Details

#contains?(namespace, scope = nil) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
# File 'lib/prx_auth/scope_list.rb', line 11

def contains?(namespace, scope=nil)
  scope, namespace = namespace, NO_NAMESPACE if scope.nil?

  if namespace == NO_NAMESPACE
    map[namespace].include?(symbolize(scope))
  else
    symbolized_scope = symbolize(scope)
    map[symbolize(namespace)].include?(symbolized_scope) || map[NO_NAMESPACE].include?(symbolized_scope)
  end
end

#freezeObject



22
23
24
25
# File 'lib/prx_auth/scope_list.rb', line 22

def freeze
  @string.freeze
  self
end