Module: Hydra::PCDM::ObjectBehavior

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

Overview

behavior:

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 
8) Hydra::PCDM::Object can have access 

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#file_of_type(uri) ⇒ Object

Finds or Initializes directly contained file with the requested RDF Type

Examples:

file_of_type(::RDF::URI("http://pcdm.org/ExtractedText"))

Parameters:

  • uri (RDF::URI)

    for the desired Type



60
61
62
63
64
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 60

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) ⇒ Object

Returns directly contained files that have the requested RDF Type

Examples:

filter_files_by_type(::RDF::URI("http://pcdm.org/ExtractedText"))

Parameters:

  • uri (RDF::URI)

    for the desired Type



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

def filter_files_by_type(uri)
  files.reject do |file|
    !file..type.include?(uri)
  end
end

#in_objectsObject



42
43
44
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 42

def in_objects
  member_of.select(&:pcdm_object?).to_a
end

#pcdm_collection?Boolean

Returns whether this instance is a PCDM Collection.

Returns:

  • (Boolean)

    whether this instance is a PCDM Collection.



38
39
40
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 38

def pcdm_collection?
  false
end

#pcdm_object?Boolean

Returns whether this instance is a PCDM Object.

Returns:

  • (Boolean)

    whether this instance is a PCDM Object.



33
34
35
# File 'lib/hydra/pcdm/models/concerns/object_behavior.rb', line 33

def pcdm_object?
  true
end