Class: Hyrax::AccessControl

Inherits:
Valkyrie::Resource
  • Object
show all
Defined in:
app/models/hyrax/access_control.rb

Overview

A list of permissions pertaining to a specific object.

‘AccessControl`s consist of a set of permissions and an `#access_to` reference to the object that set governs.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#access_toValkyrie::ID

Supports query for ACLs at the resource level. Permissions should be grouped under an AccessControl with a matching ‘#access_to` so they can be retrieved in batch.

Returns:

  • (Valkyrie::ID)

    the id of the Resource these permissions apply to



26
# File 'app/models/hyrax/access_control.rb', line 26

attribute :access_to,   Valkyrie::Types::ID

#permissionsEnumerable<Hyrax::Permission>

Returns:



26
# File 'app/models/hyrax/access_control.rb', line 26

attribute :access_to,   Valkyrie::Types::ID

Class Method Details

.for(resource:, query_service: Hyrax.query_service) ⇒ AccessControl

A finder/factory method for getting an appropriate ACL for a given resource.

Parameters:

  • resource (Valkyrie::Resource)
  • query_service (#find_inverse_references_by) (defaults to: Hyrax.query_service)

Returns:

Raises:

  • (ArgumentError)

    if the resource is not persisted



38
39
40
41
42
# File 'app/models/hyrax/access_control.rb', line 38

def self.for(resource:, query_service: Hyrax.query_service)
  query_service.custom_queries.find_access_control_for(resource: resource)
rescue Valkyrie::Persistence::ObjectNotFoundError
  new(access_to: resource.id)
end