Sha256: 8b1d1a75d7fe6f8a9eff807ed85045285d540f3e1da6a3b536951c7b75ecc4f0

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

module Elastic::Nodes
  class Nested < Base
    def self.build(_path, _child)
      new.tap do |node|
        node.path = _path
        node.child = _child
      end
    end

    attr_accessor :path, :child

    def traverse(&_block)
      super
      @child.traverse(&_block)
    end

    def clone
      prepare_clone super, @child.clone
    end

    def simplify
      prepare_clone super, @child.simplify
    end

    def render
      {
        "nested" => {
          "path" => @path,
          "query" => @child.render
        }
      }
    end

    private

    def prepare_clone(_clone, _child)
      _clone.path = @path
      _clone.child = _child
      _clone
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elastic-rails-0.5.0 lib/elastic/nodes/nested.rb