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
-
#initialize(map, reduce, view, options) ⇒ MapReduce
constructor
Initialize the builder.
-
#specification ⇒ Hash
Get the specification to pass to the map/reduce operation.
Constructor Details
#initialize(map, reduce, view, options) ⇒ MapReduce
Initialize the builder.
67 68 69 70 71 72 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 67 def initialize(map, reduce, view, ) @map = map @reduce = reduce @view = view @options = end |
Instance Attribute Details
#map ⇒ String (readonly)
Returns map The map function.
45 46 47 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 45 def map @map end |
#options ⇒ Hash (readonly)
Returns options The map/reduce specific options.
54 55 56 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 54 def @options end |
#reduce ⇒ String (readonly)
Returns reduce The reduce function.
48 49 50 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 48 def reduce @reduce end |
#view ⇒ Collection::View (readonly)
Returns view The collection view.
51 52 53 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 51 def view @view end |
Instance Method Details
#specification ⇒ Hash
Get the specification to pass to the map/reduce operation.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/mongo/collection/view/builder/map_reduce.rb', line 82 def specification spec = { selector: map_reduce_command, db_name: database.name, # Note that selector just above may also have a read preference # specified, per the #map_reduce_command method below. read: read, session: [:session] } write?(spec) ? spec.merge!(write_concern: write_concern) : spec end |