Module: Hydra::PCDM::CollectionBehavior

Extended by:
ActiveSupport::Concern
Included in:
Collection
Defined in:
lib/hydra/pcdm/models/concerns/collection_behavior.rb

Overview

Implements behavior for PCDM collections.

The behavior is summarized as:

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

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#collection_idsEnumerable<String>

Returns:

  • (Enumerable<String>)


46
47
48
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 46

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

#collectionsEnumerable<PCDM::CollectionBehavior>

Returns:



40
41
42
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 40

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

#ordered_collection_idsEnumerable<String>

Returns:

  • (Enumerable<String>)


58
59
60
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 58

def ordered_collection_ids
  ordered_collections.map(&:id)
end

#ordered_collectionsEnumerable<PCDM::CollectionBehavior>

Returns:



52
53
54
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 52

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

#pcdm_collection?Boolean

Returns whether this instance is a PCDM Collection.

Returns:

  • (Boolean)

    whether this instance is a PCDM Collection.



70
71
72
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 70

def pcdm_collection?
  true
end

#pcdm_object?Boolean

Returns whether this instance is a PCDM Object.

Returns:

  • (Boolean)

    whether this instance is a PCDM Object.



64
65
66
# File 'lib/hydra/pcdm/models/concerns/collection_behavior.rb', line 64

def pcdm_object?
  false
end