Class: DVLA::Kaping::Query
- Inherits:
-
Object
- Object
- DVLA::Kaping::Query
- Includes:
- QueryTerm
- Defined in:
- lib/dvla/kaping/query.rb
Constant Summary collapse
- BOOL =
'bool'.freeze
- MATCH =
'match'.freeze
Instance Attribute Summary collapse
-
#kwargs ⇒ Object
readonly
Returns the value of attribute kwargs.
-
#query_type ⇒ Object
readonly
Returns the value of attribute query_type.
Instance Method Summary collapse
-
#initialize(type, **kwargs) ⇒ Query
constructor
A new instance of Query.
- #to_json(*_args) ⇒ Object
Methods included from QueryTerm
#between, #current_operation, #current_params, #exists, #match, #match_phrase, #prefix, #regex, #term, #wildcard
Constructor Details
#initialize(type, **kwargs) ⇒ Query
Returns a new instance of Query.
15 16 17 18 19 20 21 |
# File 'lib/dvla/kaping/query.rb', line 15 def initialize(type, **kwargs) super() @last_operation = nil @query_type = type @operations ||= {} @kwargs = kwargs end |
Instance Attribute Details
#kwargs ⇒ Object (readonly)
Returns the value of attribute kwargs.
11 12 13 |
# File 'lib/dvla/kaping/query.rb', line 11 def kwargs @kwargs end |
#query_type ⇒ Object (readonly)
Returns the value of attribute query_type.
11 12 13 |
# File 'lib/dvla/kaping/query.rb', line 11 def query_type @query_type end |
Instance Method Details
#to_json(*_args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/dvla/kaping/query.rb', line 32 def to_json(*_args) if kwargs.empty? { query: { "#{query_type}": operations } }.to_json else { query: { "#{query_type}": kwargs } }.to_json end end |