Module: Samvera::NestingIndexer::Adapters::InMemoryAdapter::StorageModule Private

Defined in:
lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb

Overview

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

A module mixin to expose rudimentary read/write capabilities

Examples:

module Foo
  extend Samvera::NestingIndexer::StorageModule
end

Instance Method Summary collapse

Instance 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.



108
109
110
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 108

def clear_cache!
  @cache = {}
end

#find(id) ⇒ 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.



100
101
102
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 100

def find(id)
  cache.fetch(id.to_s)
end

#find_eachObject

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.



104
105
106
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 104

def find_each
  cache.each_value { |document| yield(document) }
end

#write(doc) ⇒ 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.



96
97
98
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 96

def write(doc)
  cache[doc.id] = doc
end