Module: Esse::Index::ObjectDocumentMapper

Included in:
Esse::Index
Defined in:
lib/esse/index/object_document_mapper.rb

Instance Method Summary collapse

Instance Method Details

#documents(repo_name = nil, **kwargs) ⇒ Enumerator

Wrap collection data into serialized documents

Example:

GeosIndex.documents(id: 1).first

Parameters:

  • repo_name (String, NilClass) (defaults to: nil)

    The repository identifier

Returns:

  • (Enumerator)

    All serialized entries



25
26
27
28
29
30
31
# File 'lib/esse/index/object_document_mapper.rb', line 25

def documents(repo_name = nil, **kwargs)
  Enumerator.new do |yielder|
    each_serialized_batch(repo_name, **kwargs) do |documents|
      documents.each { |document| yielder.yield(document) }
    end
  end
end

#each_serialized_batch(repo_name = nil, **kwargs) {|Array, **context| ... } ⇒ Enumerator

Wrap collection data into serialized batches

Parameters:

  • repo_name (String, NilClass) (defaults to: nil)

    The repository identifier

  • kwargs (Hash)

    The context

Yields:

  • (Array, **context)

    serialized collection and the optional context from the collection

Returns:

  • (Enumerator)

    The enumerator



12
13
14
15
16
# File 'lib/esse/index/object_document_mapper.rb', line 12

def each_serialized_batch(repo_name = nil, **kwargs, &block)
  (repo_name ? [repo(repo_name)] : repo_hash.values).each do |repo|
    repo.each_serialized_batch(**kwargs, &block)
  end
end