class ChewyQuery::Builder::Nodes::And

Public Class Methods

new(*nodes) click to toggle source
# File lib/chewy_query/builder/nodes/and.rb, line 5
def initialize(*nodes)
  @options = nodes.extract_options!
  @nodes = nodes.flatten.map{|node| node.is_a?(self.class) ? node.__nodes__ : node }.flatten
end

Public Instance Methods

__nodes__() click to toggle source
# File lib/chewy_query/builder/nodes/and.rb, line 10
def __nodes__
  @nodes
end
__render__() click to toggle source
# File lib/chewy_query/builder/nodes/and.rb, line 14
def __render__
  nodes = @nodes.map(&:__render__)

  if @options.key?(:cache)
    { and: { filters: nodes, _cache: !!@options[:cache] } }
  else
    { and: nodes }
  end
end