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', collation: 'collation' ).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.
64 65 66 67 68 69 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 64 def initialize(map, reduce, view, ) @map = map @reduce = reduce @view = view @options = end |
Instance Attribute Details
#map ⇒ String (readonly)
Returns map The map function.
42 43 44 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 42 def map @map end |
#options ⇒ Hash (readonly)
Returns options The map/reduce specific options.
51 52 53 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 51 def @options end |
#reduce ⇒ String (readonly)
Returns reduce The reduce function.
45 46 47 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 45 def reduce @reduce end |
#view ⇒ Collection::View (readonly)
Returns view The collection view.
48 49 50 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 48 def view @view end |
Instance Method Details
#command_specification ⇒ Hash
Get the specification for issuing a find command on the map/reduce results.
80 81 82 83 84 85 86 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 80 def command_specification { selector: find_command, db_name: query_database, read: read } end |
#query_specification ⇒ Hash
Get the specification for the document query after a map/reduce.
96 97 98 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 96 def query_specification { selector: {}, options: {}, db_name: query_database, coll_name: query_collection } end |
#specification ⇒ Hash
Get the specification to pass to the map/reduce operation.
108 109 110 111 112 113 114 115 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 108 def specification spec = { selector: map_reduce_command, db_name: database.name, read: read } write?(spec) ? spec.merge!(write_concern: write_concern) : spec end |