Class: CouchDB::Collection::DocumentsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/couchdb/collection.rb

Overview

A proxy class for the collection’s fetched documents.

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ DocumentsProxy

Returns a new instance of DocumentsProxy.



103
104
105
# File 'lib/couchdb/collection.rb', line 103

def initialize(collection)
  @collection = collection
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



107
108
109
110
111
112
113
114
115
# File 'lib/couchdb/collection.rb', line 107

def method_missing(method_name, *arguments, &block)
  if ARRAY_METHOD_NAMES.include?(method_name)
    @collection.options[:include_docs] = true
    @documents = @collection.map{ |row| row.document }
    @documents.send method_name, *arguments, &block
  else
    super
  end
end