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.



111
112
113
# File 'lib/couchdb/collection.rb', line 111

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



115
116
117
118
119
120
121
122
123
# File 'lib/couchdb/collection.rb', line 115

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