class Druid::PostAggregationJavascript

Public Class Methods

new(function) click to toggle source
Calls superclass method
# File lib/druid/post_aggregation.rb, line 190
def initialize(function)
  super()
  @type = 'javascript'
  @fieldNames = extract_fields(function)
  @function = function
end

Public Instance Methods

as(field) click to toggle source
# File lib/druid/post_aggregation.rb, line 201
def as(field)
  @name = field.fieldName.to_s
  self
end
field_names() click to toggle source
# File lib/druid/post_aggregation.rb, line 197
def field_names
  @fieldNames
end

Private Instance Methods

extract_fields(function) click to toggle source
# File lib/druid/post_aggregation.rb, line 208
def extract_fields(function)
  match = function.match(/function\((.+)\)/)
  raise 'Invalid Javascript function' unless match && match.captures
  match.captures.first.split(',').map(&:strip)
end