Class: Druid::PostAggregationOperation

Inherits:
PostAggregation show all
Includes:
PostAggregationOperators
Defined in:
lib/druid/post_aggregation.rb

Instance Attribute Summary

Attributes inherited from PostAggregation

#fieldName, #fieldNames, #fields, #fn, #function, #name, #numBuckets, #type, #value

Instance Method Summary collapse

Methods included from PostAggregationOperators

#*, #+, #-, #/

Methods inherited from PostAggregation

#js, #method_missing

Constructor Details

#initialize(left, operator, right) ⇒ PostAggregationOperation

Returns a new instance of PostAggregationOperation.



141
142
143
144
145
146
147
148
149
# File 'lib/druid/post_aggregation.rb', line 141

def initialize(left, operator, right)
  super()
  @type = 'arithmetic'
  @fn = operator
  @fields = [
    left.is_a?(Numeric) ? PostAggregationConstant.new(value: left) : left,
    right.is_a?(Numeric) ? PostAggregationConstant.new(value: right) : right,
  ]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Druid::PostAggregation

Instance Method Details

#as(field) ⇒ Object



151
152
153
154
# File 'lib/druid/post_aggregation.rb', line 151

def as(field)
  @name = field.fieldName.to_s
  self
end

#field_namesObject



156
157
158
# File 'lib/druid/post_aggregation.rb', line 156

def field_names
  fields.map(&:field_names).flatten.compact.uniq
end