Module: Origin::Aggregable
Overview
Provides a DSL around crafting aggregation framework commands.
Instance Attribute Summary collapse
- #aggregating Flag for whether or not we are aggregating.(Flag) ⇒ Object
- #aggregating ⇒ Object writeonly
- #pipeline ⇒ Object readonly
- #pipeline The aggregation pipeline.(Theaggregationpipeline.) ⇒ Object readonly
Instance Method Summary collapse
-
#aggregating? ⇒ true, false
Has the aggregable enter an aggregation state.
-
#group(operation) ⇒ Aggregable
Add a group ($group) operation to the aggregation pipeline.
-
#project(operation = nil) ⇒ Aggregable
Add a projection ($project) to the aggregation pipeline.
-
#unwind(field) ⇒ Aggregable
Add an unwind ($unwind) to the aggregation pipeline.
Methods included from Macroable
Instance Attribute Details
#aggregating Flag for whether or not we are aggregating.(Flag) ⇒ Object
14 |
# File 'lib/origin/aggregable.rb', line 14 attr_writer :aggregating |
#aggregating=(value) ⇒ Object (writeonly)
14 15 16 |
# File 'lib/origin/aggregable.rb', line 14 def aggregating=(value) @aggregating = value end |
#pipeline ⇒ Object (readonly)
11 12 13 |
# File 'lib/origin/aggregable.rb', line 11 def pipeline @pipeline end |
#pipeline The aggregation pipeline.(Theaggregationpipeline.) ⇒ Object (readonly)
11 |
# File 'lib/origin/aggregable.rb', line 11 attr_reader :pipeline |
Instance Method Details
#aggregating? ⇒ true, false
Has the aggregable enter an aggregation state. Ie, are only aggregation operations allowed at this point on.
25 26 27 |
# File 'lib/origin/aggregable.rb', line 25 def aggregating? !!@aggregating end |
#group(operation) ⇒ Aggregable
Add a group ($group) operation to the aggregation pipeline.
42 43 44 45 46 |
# File 'lib/origin/aggregable.rb', line 42 def group(operation) aggregation(operation) do |pipeline| pipeline.group(operation) end end |
#project(operation = nil) ⇒ Aggregable
Add a projection ($project) to the aggregation pipeline.
66 67 68 69 70 |
# File 'lib/origin/aggregable.rb', line 66 def project(operation = nil) aggregation(operation) do |pipeline| pipeline.project(operation) end end |
#unwind(field) ⇒ Aggregable
Add an unwind ($unwind) to the aggregation pipeline.
82 83 84 85 86 |
# File 'lib/origin/aggregable.rb', line 82 def unwind(field) aggregation(field) do |pipeline| pipeline.unwind(field) end end |