Class: GOM::Storage::CouchDB::View::BuilderFromClass

Inherits:
Object
  • Object
show all
Defined in:
lib/gom/storage/couchdb/view/builder_from_class.rb

Overview

Builds a javascript map-reduce-view out of a class view.

Instance Method Summary collapse

Constructor Details

#initialize(class_view) ⇒ BuilderFromClass

Returns a new instance of BuilderFromClass.



5
6
7
# File 'lib/gom/storage/couchdb/view/builder_from_class.rb', line 5

def initialize(class_view)
  @class_view = class_view
end

Instance Method Details

#map_reduce_viewObject



9
10
11
12
13
14
# File 'lib/gom/storage/couchdb/view/builder_from_class.rb', line 9

def map_reduce_view
  GOM::Storage::Configuration::View::MapReduce.new(
    "function(document) {\n  if (document['model_class'] == '#{@class_view.class_name}') {\n    emit(document['_id'], null);\n  }\n}",
    nil
  )
end