Class: Hyrax::Resource

Inherits:
Valkyrie::Resource
  • Object
show all
Includes:
Naming, WithEvents
Defined in:
app/models/hyrax/resource.rb

Overview

Note:

Hyrax permissions are managed via [Access Control List](en.wikipedia.org/wiki/Access-control_list) style permissions. Legacy Hyrax models powered by `ActiveFedora` linked the ACLs from the repository object itself (as an `acl:accessControl` link to a container). Valkyrie models jettison that approach in favor of relying on links back from the permissions using `access_to`. As was the case in the past implementation, we include an object to represent the access list itself (`Hyrax::AccessControl`). This object's `#access_to` is the way Hyrax discovers list entries–it MUST match between the `AccessControl` and its individual `Permissions`.

The effect of this change is that our `AccessControl` objects are detached from `Hyrax::Resource` they can (and usually should) be edited and persisted independently from the resource itself.

Some utilitiy methods are provided for ergonomics in transitioning from `ActiveFedora`: the `#visibility` accessor, and the `#*_users` and `#*_group` accessors. The main purpose of these is to provide a cached ACL attached to a given Resource instance. However, these will likely be deprecated in the future, and it's advisable to avoid them in favor of `Hyrax::AccessControlList`, `Hyrax::PermissionManager` and/or `Hyrax::VisibilityWriter` (which provide their underlying implementations).

The base Valkyrie model for Hyrax.

Direct Known Subclasses

AdministrativeSet, FileSet, PcdmCollection, Work

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WithEvents

#event_class, #events, #log_event, #stream

Class Method Details

.human_readable_typeString

Returns a human readable name for the model.

Returns:

  • (String)

    a human readable name for the model


49
50
51
# File 'app/models/hyrax/resource.rb', line 49

def human_readable_type
  I18n.translate("hyrax.models.#{model_name.i18n_key}", default: model_name.human)
end

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)

66
67
68
# File 'app/models/hyrax/resource.rb', line 66

def collection?
  false
end

#file?Boolean

Returns:

  • (Boolean)

72
73
74
# File 'app/models/hyrax/resource.rb', line 72

def file?
  false
end

#file_set?Boolean

Returns:

  • (Boolean)

78
79
80
# File 'app/models/hyrax/resource.rb', line 78

def file_set?
  false
end

#pcdm_object?Boolean

Returns:

  • (Boolean)

84
85
86
# File 'app/models/hyrax/resource.rb', line 84

def pcdm_object?
  false
end

#permission_managerObject


94
95
96
# File 'app/models/hyrax/resource.rb', line 94

def permission_manager
  @permission_manager ||= Hyrax::PermissionManager.new(resource: self)
end

#visibilityObject


102
103
104
# File 'app/models/hyrax/resource.rb', line 102

def visibility
  visibility_reader.read
end

#visibility=(value) ⇒ Object


98
99
100
# File 'app/models/hyrax/resource.rb', line 98

def visibility=(value)
  visibility_writer.assign_access_for(visibility: value)
end

#work?Boolean

Returns:

  • (Boolean)

90
91
92
# File 'app/models/hyrax/resource.rb', line 90

def work?
  false
end