Class: Dor::PublicDescMetadataService
- Inherits:
-
Object
- Object
- Dor::PublicDescMetadataService
- Defined in:
- lib/dor/services/public_desc_metadata_service.rb
Constant Summary collapse
- NOKOGIRI_DEEP_COPY =
1
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#doc ⇒ Nokogiri::XML::Document
A copy of the descriptiveMetadata of the object, to be modified.
-
#initialize(object) ⇒ PublicDescMetadataService
constructor
A new instance of PublicDescMetadataService.
- #ng_xml(include_access_conditions: true) ⇒ Nokogiri::XML::Document
-
#to_xml(include_access_conditions: true) ⇒ String
Public descriptive medatada XML.
Constructor Details
#initialize(object) ⇒ PublicDescMetadataService
Returns a new instance of PublicDescMetadataService.
9 10 11 |
# File 'lib/dor/services/public_desc_metadata_service.rb', line 9 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'lib/dor/services/public_desc_metadata_service.rb', line 5 def object @object end |
Instance Method Details
#doc ⇒ Nokogiri::XML::Document
Returns A copy of the descriptiveMetadata of the object, to be modified.
14 15 16 |
# File 'lib/dor/services/public_desc_metadata_service.rb', line 14 def doc @doc ||= object.descMetadata.ng_xml.dup(NOKOGIRI_DEEP_COPY) end |
#ng_xml(include_access_conditions: true) ⇒ Nokogiri::XML::Document
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dor/services/public_desc_metadata_service.rb', line 24 def ng_xml(include_access_conditions: true) @ng_xml ||= begin add_collection_reference! add_access_conditions! if include_access_conditions add_constituent_relations! strip_comments! new_doc = Nokogiri::XML(doc.to_xml, &:noblanks) new_doc.encoding = 'UTF-8' new_doc end end |
#to_xml(include_access_conditions: true) ⇒ String
Returns Public descriptive medatada XML.
19 20 21 |
# File 'lib/dor/services/public_desc_metadata_service.rb', line 19 def to_xml(include_access_conditions: true) ng_xml(include_access_conditions: include_access_conditions).to_xml end |