Module: MapReduced::Document::ClassMethods
- Defined in:
- lib/map_reduced/document.rb
Instance Attribute Summary collapse
-
#receiver_binding ⇒ Object
readonly
Returns the value of attribute receiver_binding.
Instance Method Summary collapse
- #collection ⇒ Object
- #collection_name=(name) ⇒ Object
- #db ⇒ Object
- #map_reduce(*names) ⇒ Object
- #use_functions(*names) ⇒ Object
Instance Attribute Details
#receiver_binding ⇒ Object (readonly)
Returns the value of attribute receiver_binding.
4 5 6 |
# File 'lib/map_reduced/document.rb', line 4 def receiver_binding @receiver_binding end |
Instance Method Details
#collection ⇒ Object
24 25 26 |
# File 'lib/map_reduced/document.rb', line 24 def collection db.collection(collection_name) end |
#collection_name=(name) ⇒ Object
28 29 30 |
# File 'lib/map_reduced/document.rb', line 28 def collection_name=(name) @collection_name = name end |
#db ⇒ Object
20 21 22 |
# File 'lib/map_reduced/document.rb', line 20 def db MapReduced::Config.db end |
#map_reduce(*names) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/map_reduced/document.rb', line 5 def map_reduce(*names) names.each do |name| self.class_eval %Q{ def self.run_#{name}(opts = {}) begin setup_functions collection.map_reduce(map("#{name}"), reduce("#{name}"), opts) ensure teardown_functions end end } end end |
#use_functions(*names) ⇒ Object
32 33 34 |
# File 'lib/map_reduced/document.rb', line 32 def use_functions(*names) @added_functions = names end |