Class: Elasticated::Aggregation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Clonable

#==, #clone

Methods included from BlockEvaluation

#evaluate

Constructor Details

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

Returns a new instance of Aggregation.



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

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.



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

def alias_name
  @alias_name
end

#extra_paramsObject

Returns the value of attribute extra_params.



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

def extra_params
  @extra_params
end

#fieldObject

Returns the value of attribute field.



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

def field
  @field
end

Instance Method Details

#nameObject



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

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



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

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