Sha256: a182dcfe020ce29b2b8acfc09638bd96ca7bdb4f883d9f92e4e96d1727a27e5e

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

module Hydra::PCDM
  # behavior:
  #   1) Hydra::PCDM::Collection can aggregate (pcdm:hasMember)  Hydra::PCDM::Collection (no infinite loop, e.g., A -> B -> C -> A)
  #   2) Hydra::PCDM::Collection can aggregate (pcdm:hasMember)  Hydra::PCDM::Object
  #   3) Hydra::PCDM::Collection can aggregate (ore:aggregates) Hydra::PCDM::Object  (Object related to the Collection)

  #   4) Hydra::PCDM::Collection can NOT aggregate non-PCDM object
  #   5) Hydra::PCDM::Collection can NOT contain (pcdm:hasFile)  Hydra::PCDM::File

  #   6) Hydra::PCDM::Collection can have descriptive metadata
  #   7) Hydra::PCDM::Collection can have access metadata
  #
  module CollectionBehavior
    extend ActiveSupport::Concern

    included do
      type Vocab::PCDMTerms.Collection
      include ::Hydra::PCDM::PcdmBehavior
    end

    module ClassMethods
      def indexer
        Hydra::PCDM::CollectionIndexer
      end

      def type_validator
      end
    end

    def collections
      members.select(&:pcdm_collection?)
    end

    def collection_ids
      members.select(&:pcdm_collection?).map(&:id)
    end

    def ordered_collections
      ordered_members.to_a.select(&:pcdm_collection?)
    end

    def ordered_collection_ids
      ordered_collections.map(&:id)
    end

    def pcdm_object?
      false
    end

    def pcdm_collection?
      true
    end

    def child_collections
      warn '[DEPRECATION] `child_collections` is deprecated in Hydra::PCDM.  Please use `collections` instead.  This has a target date for removal of 10-31-2015'
      ordered_collections
    end

    def child_collection_ids
      warn '[DEPRECATION] `child_collection_ids` is deprecated in Hydra::PCDM.  Please use `collection_ids` instead.  This has a target date for removal of 10-31-2015'
      ordered_collection_ids
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-pcdm-0.3.2 lib/hydra/pcdm/models/concerns/collection_behavior.rb
hydra-pcdm-0.3.1 lib/hydra/pcdm/models/concerns/collection_behavior.rb
hydra-pcdm-0.3.0 lib/hydra/pcdm/models/concerns/collection_behavior.rb