Class: MarkLogic::Queries::OrQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/marklogic/queries/or_query.rb

Instance Method Summary collapse

Methods inherited from BaseQuery

#add_sub_query, #query_value

Constructor Details

#initialize(*args) ⇒ OrQuery

Returns a new instance of OrQuery.


4
5
6
# File 'lib/marklogic/queries/or_query.rb', line 4

def initialize(*args)
  @queries = args.flat_map{ |i| i }
end

Instance Method Details

#to_jsonObject


8
9
10
11
12
13
14
15
16
# File 'lib/marklogic/queries/or_query.rb', line 8

def to_json
  {
    "or-query" => {
      "queries" => @queries.map do |q|
        q.to_json
      end
    }
  }
end

#to_xqyObject


18
19
20
21
# File 'lib/marklogic/queries/or_query.rb', line 18

def to_xqy
  sub_queries = @queries.map { |q| q.to_xqy }.join(', ')
  %Q{cts:or-query((#{sub_queries}))}
end