Class: Elasticband::Aggregation::Nested

Inherits:
Elasticband::Aggregation show all
Defined in:
lib/elasticband/aggregation/nested.rb

Constant Summary

Constants inherited from Elasticband::Aggregation

PARSE_AGGREGATIONS

Instance Attribute Summary collapse

Attributes inherited from Elasticband::Aggregation

#name

Instance Method Summary collapse

Methods inherited from Elasticband::Aggregation

merge, parse

Constructor Details

#initialize(root_aggregation, nested_aggregations) ⇒ Nested

Returns a new instance of Nested.



6
7
8
9
# File 'lib/elasticband/aggregation/nested.rb', line 6

def initialize(root_aggregation, nested_aggregations)
  self.root_aggregation = root_aggregation
  self.nested_aggregations = Array.wrap(nested_aggregations)
end

Instance Attribute Details

#nested_aggregationsObject

Returns the value of attribute nested_aggregations.



4
5
6
# File 'lib/elasticband/aggregation/nested.rb', line 4

def nested_aggregations
  @nested_aggregations
end

#root_aggregationObject

Returns the value of attribute root_aggregation.



4
5
6
# File 'lib/elasticband/aggregation/nested.rb', line 4

def root_aggregation
  @root_aggregation
end

Instance Method Details

#to_hObject



11
12
13
14
15
# File 'lib/elasticband/aggregation/nested.rb', line 11

def to_h
  root_aggregation.to_h.tap do |h|
    h[root_aggregation.name].merge!(aggs: nested_hash)
  end
end