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.



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

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.



91
92
93
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 91

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.



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

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.



87
88
89
# File 'lib/samvera/nesting_indexer/adapters/in_memory_adapter.rb', line 87

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