Sha256: 170160bc301509cc8a71da60b4625919eb9365bbf5a7ff66aa5bbfe87f860228

Contents?: true

Size: 944 Bytes

Versions: 30

Compression:

Stored size: 944 Bytes

Contents

module ActiveFedora
  # This is the base class for ldp containers, it is not an ldp:BasicContainer
  class Container < ActiveFedora::Base
    property :membership_resource, predicate: ::RDF::Vocab::LDP.membershipResource
    property :has_member_relation, predicate: ::RDF::Vocab::LDP.hasMemberRelation
    property :is_member_of_relation, predicate: ::RDF::Vocab::LDP.isMemberOfRelation
    property :contained, predicate: ::RDF::Vocab::LDP.contains

    def parent
      @parent || raise("Parent hasn't been set on #{self.class}")
    end

    def parent=(parent)
      @parent = parent
      self.membership_resource = [::RDF::URI(parent.uri)]
    end

    def mint_id
      "#{id}/#{SecureRandom.uuid}"
    end

    def self.find_or_initialize(id)
      find(id)
    rescue ActiveFedora::ObjectNotFoundError
      new(id)
    end

    private

      # Don't allow directly setting contained
      def contained=(*_args)
      end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
active-fedora-9.10.0.pre1 lib/active_fedora/containers/container.rb
active-fedora-9.9.1 lib/active_fedora/containers/container.rb
active-fedora-9.9.0 lib/active_fedora/containers/container.rb
active-fedora-9.8.2 lib/active_fedora/containers/container.rb
active-fedora-9.8.1 lib/active_fedora/containers/container.rb
active-fedora-9.8.0 lib/active_fedora/containers/container.rb
active-fedora-9.7.1 lib/active_fedora/containers/container.rb
active-fedora-9.7.0 lib/active_fedora/containers/container.rb
active-fedora-9.6.2 lib/active_fedora/containers/container.rb
active-fedora-9.6.1 lib/active_fedora/containers/container.rb