Sha256: a3ef2be886dbb387df0738f013aece67e5c0135cef58879f14270ffcac227188

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

module Elastic::Results
  class Aggregations < Base
    include Enumerable

    attr_reader :key

    def initialize(_aggs)
      @aggs = _aggs
    end

    def [](_key)
      @aggs[_key.to_s].try(:as_value)
    end

    def each(&_block)
      @aggs.each(&_block)
    end

    def as_value
      # TODO: return aggregation value if configured as single bucket
      self
    end

    def traverse(&_block)
      super
      @aggs.each_value { |a| a.traverse(&_block) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elastic-rails-0.5.0 lib/elastic/results/aggregations.rb