Class Rddb::DocumentStore::RamDocumentStore
In: lib/rddb/document_store/ram_document_store.rb
Parent: Base

DocumentStore implementation that stores documents in a Hash in memory.

Methods

count   delete   each   each_partition   exists?   find   new   store  

Public Class methods

Initialize the datastore.

[Source]

   # File lib/rddb/document_store/ram_document_store.rb, line 7
7:       def initialize(options={})
8:         @options = options
9:       end

Public Instance methods

The number of documents in the datastore

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 32
32:       def count
33:         documents.length
34:       end

Delete the document at the given path.

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 22
22:       def delete(id)
23:         documents.delete(id.to_s)
24:       end

Yield each document from the datastore to the given block

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 37
37:       def each(partition=nil, &block)
38:         documents.each do |id, document|
39:           yield document
40:         end
41:       end

Yield each partition name

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 44
44:       def each_partition(&block)
45:         yield 'default'
46:       end

Return true if the document exists.

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 27
27:       def exists?(id)
28:         documents.key?(id.to_s)
29:       end

Find the document for the given id.

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 12
12:       def find(id)
13:         documents[id.to_s]
14:       end

Store the document.

[Source]

    # File lib/rddb/document_store/ram_document_store.rb, line 17
17:       def store(document)
18:         documents[document.id.to_s] = document
19:       end

[Validate]