Class: Mongo::Collection::View::Builder::MapReduce
- Inherits:
-
Object
- Object
- Mongo::Collection::View::Builder::MapReduce
- Extended by:
- Forwardable
- Defined in:
- lib/mongo/collection/view/builder/map_reduce.rb
Overview
Builds a map/reduce specification from the view and options.
Constant Summary collapse
- MAPPINGS =
The mappings from ruby options to the map/reduce options.
BSON::Document.new( finalize: 'finalize', js_mode: 'jsMode', out: 'out', scope: 'scope', verbose: 'verbose', bypass_document_validation: 'bypassDocumentValidation' ).freeze
Instance Attribute Summary collapse
-
#map ⇒ String
readonly
Map The map function.
-
#options ⇒ Hash
readonly
Options The map/reduce specific options.
-
#reduce ⇒ String
readonly
Reduce The reduce function.
-
#view ⇒ Collection::View
readonly
View The collection view.
Instance Method Summary collapse
-
#command_specification ⇒ Hash
Get the specification for issuing a find command on the map/reduce results.
-
#initialize(map, reduce, view, options) ⇒ MapReduce
constructor
Initialize the builder.
-
#query_specification ⇒ Hash
Get the specification for the document query after a map/reduce.
-
#specification ⇒ Hash
Get the specification to pass to the map/reduce operation.
Constructor Details
#initialize(map, reduce, view, options) ⇒ MapReduce
Initialize the builder.
63 64 65 66 67 68 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 63 def initialize(map, reduce, view, ) @map = map @reduce = reduce @view = view = end |
Instance Attribute Details
#map ⇒ String (readonly)
Returns map The map function.
41 42 43 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 41 def map @map end |
#options ⇒ Hash (readonly)
Returns options The map/reduce specific options.
50 51 52 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 50 def end |
#reduce ⇒ String (readonly)
Returns reduce The reduce function.
44 45 46 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 44 def reduce @reduce end |
#view ⇒ Collection::View (readonly)
Returns view The collection view.
47 48 49 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 47 def view @view end |
Instance Method Details
#command_specification ⇒ Hash
Get the specification for issuing a find command on the map/reduce results.
79 80 81 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 79 def command_specification { selector: find_command, db_name: database.name, read: read } end |
#query_specification ⇒ Hash
Get the specification for the document query after a map/reduce.
91 92 93 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 91 def query_specification { selector: {}, options: {}, db_name: database.name, coll_name: query_collection } end |
#specification ⇒ Hash
Get the specification to pass to the map/reduce operation.
103 104 105 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 103 def specification { selector: map_reduce_command, db_name: database.name, read: read } end |