Class: Checkpoint::Resource::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/checkpoint/resource/resolver.rb

Overview

A Resource Resolver takes a concrete object (like a model instance) and resolves it into all Checkpoint::Resources for which a permit would allow an action. For example, this can be used to grant a credential on all items of a given model class or to implement cascading permissions when all credentials for a container should apply to the contained objects.

NOTE: This implementation currently always resolves to the entity and its type and nothing more. This needs some thought on an appropriate extension mechanism to mirror the PermissionMapper.

Instance Method Summary collapse

Instance Method Details

#resolve(target) ⇒ Object



15
16
17
18
# File 'lib/checkpoint/resource/resolver.rb', line 15

def resolve(target)
  return [target] if target.is_a?(Resource)
  [Resource.from(target), Resource::AllOfType.from(target)]
end