Class: Noiseless::AST::AggregationBuilder
- Inherits:
-
Object
- Object
- Noiseless::AST::AggregationBuilder
- Defined in:
- lib/noiseless/ast/aggregation.rb
Instance Attribute Summary collapse
-
#aggregations ⇒ Object
readonly
Returns the value of attribute aggregations.
Instance Method Summary collapse
- #agg(name, type, field: nil) ⇒ Object (also: #aggregation)
-
#initialize ⇒ AggregationBuilder
constructor
A new instance of AggregationBuilder.
Constructor Details
#initialize ⇒ AggregationBuilder
Returns a new instance of AggregationBuilder.
36 37 38 |
# File 'lib/noiseless/ast/aggregation.rb', line 36 def initialize @aggregations = [] end |
Instance Attribute Details
#aggregations ⇒ Object (readonly)
Returns the value of attribute aggregations.
34 35 36 |
# File 'lib/noiseless/ast/aggregation.rb', line 34 def aggregations @aggregations end |
Instance Method Details
#agg(name, type, field: nil) ⇒ Object Also known as: aggregation
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/noiseless/ast/aggregation.rb', line 40 def agg(name, type, field: nil, **, &) sub_aggs = [] if block_given? sub_builder = AggregationBuilder.new sub_builder.instance_eval(&) sub_aggs = sub_builder.aggregations end aggregation = Aggregation.new(name, type, field: field, sub_aggregations: sub_aggs, **) @aggregations << aggregation aggregation end |