Module: MongoModel::MapReduce::ClassMethods
- Defined in:
- lib/mongomodel/concerns/map_reduce.rb
Instance Method Summary collapse
- #cached ⇒ Object
- #collection ⇒ Object
- #collection_name ⇒ Object
- #collection_name=(name) ⇒ Object
- #database ⇒ Object
- #default_collection_name ⇒ Object
- #from_mongo(attrs) ⇒ Object
- #map_function ⇒ Object
- #map_reduce_options ⇒ Object
- #reduce_function ⇒ Object
Instance Method Details
#cached ⇒ Object
15 16 17 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 15 def cached from(collection_name) end |
#collection ⇒ Object
23 24 25 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 23 def collection parent_collection.map_reduce(map_function, reduce_function, ) end |
#collection_name ⇒ Object
27 28 29 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 27 def collection_name @_collection_name || default_collection_name end |
#collection_name=(name) ⇒ Object
31 32 33 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 31 def collection_name=(name) @_collection_name = name end |
#database ⇒ Object
19 20 21 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 19 def database parent_collection.db end |
#default_collection_name ⇒ Object
35 36 37 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 35 def default_collection_name [parent_collection.name, name.demodulize.tableize.gsub(/\//, '.')].join("._") end |
#from_mongo(attrs) ⇒ Object
11 12 13 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 11 def from_mongo(attrs) new(attrs['_id'], attrs['value']) end |
#map_function ⇒ Object
39 40 41 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 39 def map_function raise NotImplementedError, "map_function is not implemented" end |
#map_reduce_options ⇒ Object
47 48 49 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 47 def { :out => collection_name } end |
#reduce_function ⇒ Object
43 44 45 |
# File 'lib/mongomodel/concerns/map_reduce.rb', line 43 def reduce_function raise NotImplementedError, "reduce_function is not implemented" end |