Class: Chewy::Query::Nodes::Or

Inherits:
Expr show all
Defined in:
lib/chewy/query/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/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/nodes/or.rb', line 10

def __nodes__
  @nodes
end

#__render__Object



14
15
16
17
18
19
20
21
# File 'lib/chewy/query/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