module Aggregations::Helpers::AggregationQueryBuilderHelper
Constants
- OBJECT_ARRAY_QUERY_FIELDS
- OBJECT_ARRAY_SETTINGS_FIELDS
Public Instance Methods
name_expr()
click to toggle source
@return [String] : Aggregation name
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 10 def name_expr @name.to_s end
query()
click to toggle source
@return [Hash] : Aggregation query
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 20 def query add_value_source_agg_builder if self.class.included_modules.include?(ValuesSourceAggregationHelper) add_abstract_agg_builder if self.class.included_modules.include?(AbstractAggregationHelper) add_abstract_range_builder if self.class.included_modules.include?(AbstractRangeHelper) add_class_attributes if ("#{self.class.name}::ATTRIBUTES".constantize rescue nil).present? @query end
Also aliased as: query_expr
type_expr()
click to toggle source
@return [String] : Aggregation type
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 15 def type_expr @type.to_s end
Private Instance Methods
add_abstract_agg_builder()
click to toggle source
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 51 def add_abstract_agg_builder @query[@name].merge!(abstract_agg_builder) end
add_abstract_range_builder()
click to toggle source
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 55 def add_abstract_range_builder @query[@name][@type].merge!(abstract_range_builder) end
add_class_attributes()
click to toggle source
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 36 def add_class_attributes "#{self.class.name}::ATTRIBUTES".constantize.each do |attr| attr_inst = instance_variable_get("@#{attr.to_s}") if attr_inst.present? if OBJECT_ARRAY_SETTINGS_FIELDS.include?(attr) @query[@name][@type][attr] = attr_inst.map{|obj| obj.settings} elsif OBJECT_ARRAY_QUERY_FIELDS.include?(attr) @query[@name][@type][attr] = attr_inst.map{|obj| obj.query} else @query[@name][@type][attr] = attr_inst end end end end
add_value_source_agg_builder()
click to toggle source
# File lib/aggregations/helpers/aggregation_query_builder_helper.rb, line 32 def add_value_source_agg_builder @query[@name][@type].merge!(value_source_agg_builder) end