Sha256: 3a9e19dcecc05c014cbbc2c763be172ca921c592cf6285f5ab8c46a5dcc929ba

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Test
    ##
    # A simple Hyrax::Resource with some metadata.
    #
    # Use this for testing valkyrie models generically, with Hyrax assumptions
    # but no PCDM modelling behavior.
    class BookResource < Hyrax::Resource
      attribute :author,    Valkyrie::Types::String
      attribute :created,   Valkyrie::Types::Date
      attribute :isbn,      Valkyrie::Types::String
      attribute :publisher, Valkyrie::Types::String
      attribute :title,     Valkyrie::Types::String
    end

    ##
    # A simple Hyrax::ChangeSet with one custom validation.
    #
    # Hyrax::Test::BookResource will use this based on naming convention by adding `ChangeSet`
    # to the end of the resource class name.
    class BookResourceChangeSet < Hyrax::ChangeSet
      validates :isbn, presence: true
    end

    class Book < ActiveFedora::Base
      property :author,    predicate: ::RDF::URI('http://example.com/ns/author')
      property :created,   predicate: ::RDF::URI('http://example.com/ns/created')
      property :isbn,      predicate: ::RDF::URI('http://example.com/ns/isbn')
      property :publisher, predicate: ::RDF::URI('http://example.com/ns/publisher')
      property :title,     predicate: ::RDF::URI("http://example.com/ns/title")
    end
  end
end

Wings::ModelRegistry.register(Hyrax::Test::BookResource, Hyrax::Test::Book) if defined?(Wings)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyrax-5.0.0 spec/support/book_resource.rb
hyrax-5.0.0.rc3 spec/support/book_resource.rb