-
Notifications
You must be signed in to change notification settings - Fork 41
Lesson Create a Model that can track rightsMetadata
This Tutorial is known to work with hydra-head version 6.4.0.
Please update this wiki to reflect any other versions that have been tested.
Add this line to an ActiveFedora model
include Hydra::AccessControls::Permissions
By convention, the include statements should be at the very beginning of your class definition, so if you're using the Book model from Dive into Hydra it might look like this with the above line added
class Book < ActiveFedora::Base
# This is the include statement
include Hydra::AccessControls::Permissions
has_metadata 'descMetadata', type: BookMetadata
delegate :title, to: 'descMetadata'
delegate :author, to: 'descMetadata'
end
Including Hydra::AccessControls::Permissions
will automatically call has_metadata "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
to define the rightsMetadata datastream.
Save the file.
Restart the rails console
and run
book = Book.new
book.rightsMetadata.class
=> Hydra::Datastream::RightsMetadata
book.permissions
=> []
As you can see, rightsMetadata is a Hydra::Datastream::RightsMetadata Datastream and the methods provided by Hydra::AccessControls::Permissions, such as .permissions
have been mixed into the Book model. Now you're ready to use these things to assert permissions on objects.
Go on to Lesson - Set permissions on an object or return to the Access Controls with Hydra tutorial.