Module: Samvera::NestingIndexer::Adapters::InMemoryAdapter

Extended by:
AbstractAdapter
Defined in:
lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb

Overview

Defines the interface for interacting with the InMemory layer. It is a reference implementation that is used throughout tests.

Defined Under Namespace

Modules: StorageModule

Class Method Summary collapse

Class Method Details

.clear_cache!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
79
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 76

def self.clear_cache!
  Preservation.clear_cache!
  Index.clear_cache!
end

.each_child_document_of(document:) {|Samvera::NestingIndexer::Documents::IndexDocument| ... } ⇒ Object



43
44
45
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 43

def self.each_child_document_of(document:, &block)
  Index.each_child_document_of(document: document, &block)
end

.each_index_document(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A convenience method for testing



83
84
85
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 83

def self.each_index_document(&block)
  Index.each_index_document(&block)
end

.each_perservation_document_id_and_parent_ids {|id, parent_ids| ... } ⇒ Object

Yield Parameters:

  • id (String)

    The ‘id` of the preservation document

  • parent_ids (String)

    The ids of the parent objects of this presevation document



30
31
32
33
34
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 30

def self.each_perservation_document_id_and_parent_ids(&block)
  Preservation.find_each do |document|
    block.call(document.id, document.parent_ids)
  end
end

.find_index_document_by(id:) ⇒ Samvera::NestingIndexer::Documents::IndexDocument

Parameters:

  • id (String)

Returns:



23
24
25
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 23

def self.find_index_document_by(id:)
  Index.find(id)
end

.find_preservation_document_by(id:) ⇒ Object

Returns Samvera::NestingIndexer::Document::PreservationDocument.

Parameters:

  • id (String)

Returns:

  • Samvera::NestingIndexer::Document::PreservationDocument



16
17
18
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 16

def self.find_preservation_document_by(id:)
  Preservation.find(id)
end

.find_preservation_parent_ids_for(id:) ⇒ Object



36
37
38
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 36

def self.find_preservation_parent_ids_for(id:)
  Preservation.find(id).parent_ids
end

.write_document_attributes_to_index_layer(id:, parent_ids:, ancestors:, pathnames:, deepest_nested_depth:) ⇒ Hash

Returns - the attributes written to the indexing layer.

Parameters:

  • id (String)
  • parent_ids (Array<String>)
  • ancestors (Array<String>)
  • pathnames (Array<String>)
  • deepest_nested_depth (Integer)

Returns:

  • (Hash)
    • the attributes written to the indexing layer

See Also:

  • README.md


64
65
66
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 64

def self.write_document_attributes_to_index_layer(id:, parent_ids:, ancestors:, pathnames:, deepest_nested_depth:)
  Index.write_document(id: id, parent_ids: parent_ids, ancestors: ancestors, pathnames: pathnames, deepest_nested_depth: deepest_nested_depth)
end

.write_document_attributes_to_preservation_layer(attributes) ⇒ Samvera::NestingIndexer::Documents::PreservationDocument

This is not something that I envision using in the production environment; It is hear to keep the Preservation system isolated and accessible only through interfaces.

Parameters:

  • attributes (Hash)

Returns:



52
53
54
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 52

def self.write_document_attributes_to_preservation_layer(attributes)
  Preservation.write_document(attributes)
end

.write_nesting_document_to_index_layer(nesting_document:) ⇒ Object

Parameters:

See Also:

  • README.md


71
72
73
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 71

def self.write_nesting_document_to_index_layer(nesting_document:)
  Index.write_to_storage(nesting_document)
end