Module: Curate::Indexer::Adapters::InMemoryAdapter::StorageModule Private

Defined in:
lib/curate/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 Curate::Indexer::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.



81
82
83
# File 'lib/curate/indexer/adapters/in_memory_adapter.rb', line 81

def clear_cache!
  @cache = {}
end

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



73
74
75
# File 'lib/curate/indexer/adapters/in_memory_adapter.rb', line 73

def find(pid)
  cache.fetch(pid.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.



77
78
79
# File 'lib/curate/indexer/adapters/in_memory_adapter.rb', line 77

def find_each
  cache.each { |_key, 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.



69
70
71
# File 'lib/curate/indexer/adapters/in_memory_adapter.rb', line 69

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