class PrxAuth::ResourceMap
Constants
- WILDCARD_KEY
Public Class Methods
new(mapped_values)
click to toggle source
# File lib/prx_auth/resource_map.rb, line 5 def initialize(mapped_values) input = mapped_values.clone @wildcard = ScopeList.new(input.delete(WILDCARD_KEY)||'') @map = Hash[input.map do |(key, values)| [key, ScopeList.new(values)] end] end
Public Instance Methods
contains?(resource, namespace=nil, scope=nil)
click to toggle source
# File lib/prx_auth/resource_map.rb, line 13 def contains?(resource, namespace=nil, scope=nil) resource = resource.to_s if resource == WILDCARD_KEY raise ArgumentError if namespace.nil? @wildcard.contains?(namespace, scope) else mapped_resource = @map[resource] if mapped_resource && !namespace.nil? mapped_resource.contains?(namespace, scope) || @wildcard.contains?(namespace, scope) elsif !namespace.nil? @wildcard.contains?(namespace, scope) else !!mapped_resource end end end
freeze()
click to toggle source
# File lib/prx_auth/resource_map.rb, line 33 def freeze @map.freeze @wildcard.freeze self end
resources(namespace=nil, scope=nil)
click to toggle source
# File lib/prx_auth/resource_map.rb, line 39 def resources(namespace=nil, scope=nil) if namespace.nil? @map.keys else @map.select do |name, list| list.contains?(namespace, scope) end.map(&:first) end end