Class: Elasticated::Aggregation

Inherits:
Object
  • Object
show all
Includes:
Mixins::BlockEvaluation, Mixins::Clonable, Mixins::Inspectionable
Defined in:
lib/elasticated/aggregation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Inspectionable

#inspect, #text_for_inspect

Methods included from Mixins::BlockEvaluation

#evaluate

Methods included from Mixins::Clonable

#==, #clone

Constructor Details

#initialize(field, *args, &block) ⇒ Aggregation

Returns a new instance of Aggregation.



25
26
27
28
29
30
31
32
33
34
# File 'lib/elasticated/aggregation.rb', line 25

def initialize(field, *args, &block)
  self.field = field
  opts = args.last
  if opts.is_a? Hash
    self.extra_params = Helpers.hash_deep_dup opts
    self.alias_name = extra_params.delete :as
  else
    self.extra_params = Hash.new
  end
end

Instance Attribute Details

#alias_nameObject

Returns the value of attribute alias_name.



13
14
15
# File 'lib/elasticated/aggregation.rb', line 13

def alias_name
  @alias_name
end

#extra_paramsObject

Returns the value of attribute extra_params.



13
14
15
# File 'lib/elasticated/aggregation.rb', line 13

def extra_params
  @extra_params
end

#fieldObject

Returns the value of attribute field.



13
14
15
# File 'lib/elasticated/aggregation.rb', line 13

def field
  @field
end

Instance Method Details

#nameObject



15
16
17
18
# File 'lib/elasticated/aggregation.rb', line 15

def name
  return Helpers.string_to_agg_name(alias_name).to_sym if alias_name
  Helpers.string_to_agg_name(default_name).to_sym
end

#original_nameObject



20
21
22
23
# File 'lib/elasticated/aggregation.rb', line 20

def original_name
  return alias_name.to_sym if alias_name
  default_name.to_s.to_sym
end