Class: ChewyQuery::Builder::Nodes::Or

Inherits:
Expr
  • Object
show all
Defined in:
lib/chewy_query/builder/nodes/or.rb

Instance Method Summary collapse

Methods inherited from Expr

#!, #&, #|, #~

Methods inherited from Base

#eql?, #render

Constructor Details

#initialize(*nodes) ⇒ Or

Returns a new instance of Or.



5
6
7
8
# File 'lib/chewy_query/builder/nodes/or.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

Instance Method Details

#__nodes__Object



10
11
12
# File 'lib/chewy_query/builder/nodes/or.rb', line 10

def __nodes__
  @nodes
end

#__render__Object



14
15
16
17
18
19
20
21
22
# File 'lib/chewy_query/builder/nodes/or.rb', line 14

def __render__
  nodes = @nodes.map(&:__render__)

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