Module: Hydra::PCDM::ObjectBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- Object
- Defined in:
- lib/hydra/pcdm/models/concerns/object_behavior.rb
Overview
Implements behavior for PCDM objects.
The behavior is summarized as:
1) Hydra::PCDM::Object can aggregate (pcdm:hasMember) Hydra::PCDM::Object
2) Hydra::PCDM::Object can aggregate (ore:aggregates) Hydra::PCDM::Object (Object related to the Object)
3) Hydra::PCDM::Object can contain (pcdm:hasFile) Hydra::PCDM::File
4) Hydra::PCDM::Object can contain (pcdm:hasRelatedFile) Hydra::PCDM::File
5) Hydra::PCDM::Object can NOT aggregate Hydra::PCDM::Collection
6) Hydra::PCDM::Object can NOT aggregate non-PCDM object
7) Hydra::PCDM::Object can have descriptive metadata
8) Hydra::PCDM::Object can have access metadata
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#file_of_type(uri) ⇒ ActiveFedora::File
Finds or Initializes directly contained file with the requested RDF Type.
-
#filter_files_by_type(uri) ⇒ Enumerable<ActiveFedora::File>
Gives directly contained files that have the requested RDF Type.
- #in_objects ⇒ Enumerable<Hydra::PCDM::ObjectBehavior>
-
#pcdm_collection? ⇒ Boolean
Whether this instance is a PCDM Collection.
-
#pcdm_object? ⇒ Boolean
Whether this instance is a PCDM Object.
Instance Method Details
#file_of_type(uri) ⇒ ActiveFedora::File
Finds or Initializes directly contained file with the requested RDF Type
110 111 112 113 114 |
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 110 def file_of_type(uri) matching_files = filter_files_by_type(uri) return matching_files.first unless matching_files.empty? Hydra::PCDM::AddTypeToFile.call(files.build, uri) end |
#filter_files_by_type(uri) ⇒ Enumerable<ActiveFedora::File>
Gives directly contained files that have the requested RDF Type
96 97 98 99 100 |
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 96 def filter_files_by_type(uri) files.reject do |file| !file..type.include?(uri) end end |
#in_objects ⇒ Enumerable<Hydra::PCDM::ObjectBehavior>
84 85 86 |
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 84 def in_objects member_of.select(&:pcdm_object?).to_a end |
#pcdm_collection? ⇒ Boolean
Returns whether this instance is a PCDM Collection.
78 79 80 |
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 78 def pcdm_collection? false end |
#pcdm_object? ⇒ Boolean
Returns whether this instance is a PCDM Object.
72 73 74 |
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 72 def pcdm_object? true end |