-
Notifications
You must be signed in to change notification settings - Fork 0
Valkyrie
Tutorial: Dive into Valkyrie
Defining resources is basically the same as for a non-Hyrax Valkyrie app. But it inherits from Hyrax::Resource instead of Valkyrie::Resource. In this case the resource is supporting and not part of the PCDM model.
# frozen_string_literal: true
class CollectionType < Hyrax::Resource
attribute :title, Valkyrie::Types::String
attribute :description, Valkyrie::Types::String
attribute :machine_id, Valkyrie::Types::ID
end
# frozen_string_literal: true
class Book < Hyrax::Work # Hyrax::Work isa Hyrax::Resource isa Valkyrie::Resource
include Hyrax::Schema(:core_metadata)
attribute :author, Valkyrie::Types::Set.of(Valkyrie::Types::String).meta(ordered: true)
attribute :series, Valkyrie::Types::String.optional
end
NOTE: This produces basically the same attribute definitions as those created for the Valkyrie app. The title attribute is defined by the Hyrax::Schema. The member_ids attribute is defined by Hyrax::Work.
NOTE: You could also use include Hyrax::Schema(:basic_metadata) to use the default metadata defined by Hyrax instead of defining it all in the Book work.
Core and Basic metadata defined in... https://github.com/samvera/hyrax/tree/master/config/metadata
These are loaded using... https://github.com/samvera/hyrax/blob/master/app/services/hyrax/simple_schema_loader.rb
# frozen_string_literal: true
class Page < Hyrax::Work
include Hyrax::Schema(:core_metadata)
attribute :page_num, Valkyrie::Types::String.optional
attribute :structure, Valkyrie::Types::String.optional
attribute :image_id, Valkyrie::Types::ID.optional
end