Class: Longleaf::MetadataPersistenceManager
- Inherits:
-
Object
- Object
- Longleaf::MetadataPersistenceManager
- Defined in:
- lib/longleaf/services/metadata_persistence_manager.rb
Overview
Handles the persistence of metadata records
Instance Method Summary collapse
-
#index(file_rec) ⇒ Object
Index metadata for the provided file record.
-
#initialize(index_manager) ⇒ MetadataPersistenceManager
constructor
Initialize the MetadataPersistenceManager.
-
#load(file_rec) ⇒ MetadataRecord
Load the metadata record for the provided file record.
-
#persist(file_rec) ⇒ Object
Persist the metadata for the provided file record to all configured destinations.
Constructor Details
#initialize(index_manager) ⇒ MetadataPersistenceManager
Initialize the MetadataPersistenceManager
10 11 12 |
# File 'lib/longleaf/services/metadata_persistence_manager.rb', line 10 def initialize(index_manager) @index_manager = index_manager end |
Instance Method Details
#index(file_rec) ⇒ Object
Index metadata for the provided file record
31 32 33 34 35 |
# File 'lib/longleaf/services/metadata_persistence_manager.rb', line 31 def index(file_rec) if @index_manager.using_index? @index_manager.index(file_rec) end end |
#load(file_rec) ⇒ MetadataRecord
Load the metadata record for the provided file record
40 41 42 43 44 45 |
# File 'lib/longleaf/services/metadata_persistence_manager.rb', line 40 def load(file_rec) md_rec = MetadataDeserializer.deserialize(file_path: file_rec., digest_algs: file_rec.storage_location..digests) file_rec. = md_rec md_rec end |
#persist(file_rec) ⇒ Object
Persist the metadata for the provided file record to all configured destinations. This may include to disk as well as to an index.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/longleaf/services/metadata_persistence_manager.rb', line 17 def persist(file_rec) if file_rec..nil? raise MetadataError.new("No metadata record provided, cannot persist metadata for #{file_rec.path}") end MetadataSerializer::write(metadata: file_rec., file_path: file_rec., digest_algs: file_rec.storage_location..digests) index(file_rec) end |