Class: Dor::DatastreamBuilder
- Inherits:
-
Object
- Object
- Dor::DatastreamBuilder
- Defined in:
- lib/dor/services/datastream_builder.rb
Overview
The ContentMetadata and DescMetadata robot are allowed to build the datastream by reading a file from the /dor/workspace that matches the datastream name. This allows assembly or pre-assembly to prebuild the datastreams from templates or using other means (like the assembly-objectfile gem) and then have those datastreams picked up and added to the object during accessionWF.
This class builds that datastream using the content of a file if such a file exists and is newer than the object’s current datastream (see above); otherwise, builds the datastream by calling build_fooMetadata_datastream.
Instance Method Summary collapse
- #build ⇒ Object
- #initialize(object:, datastream:, force: false, required: false) ⇒ ActiveFedora::Datastream constructor
Constructor Details
#initialize(object:, datastream:, force: false, required: false) ⇒ ActiveFedora::Datastream
20 21 22 23 24 25 26 |
# File 'lib/dor/services/datastream_builder.rb', line 20 def initialize(object:, datastream:, force: false, required: false) @object = object @datastream = datastream @force = force @required = required @filename = end |
Instance Method Details
#build ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dor/services/datastream_builder.rb', line 28 def build # See if datastream exists as a file and if the file's timestamp is newer than datastream's timestamp. if file_newer_than_datastream? create_from_file(filename) elsif force || empty_datastream? create_default end # Check for success. raise "Required datastream #{datastream_name} could not be populated!" if required && empty_datastream? end |