Class: Elasticquery::Base
- Inherits:
-
Object
- Object
- Elasticquery::Base
- Includes:
- Builder
- Defined in:
- lib/elasticquery/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
- #filterable? ⇒ Boolean
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Builder
#exists, #filters, #missing, #multi_match, #not, #queries, #range, #search, #term, #terms, #where, #with, #without
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
23 24 25 26 |
# File 'lib/elasticquery/base.rb', line 23 def initialize(params = {}) @params = params @query = Query.new end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/elasticquery/base.rb', line 11 def params @params end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
11 12 13 |
# File 'lib/elasticquery/base.rb', line 11 def query @query end |
Class Method Details
.build(params = {}) ⇒ Object
34 35 36 |
# File 'lib/elasticquery/base.rb', line 34 def self.build(params = {}) new(params).build end |
.filtered(&block) ⇒ Object
15 16 17 |
# File 'lib/elasticquery/base.rb', line 15 def self.filtered(&block) self.rules += [block] end |
Instance Method Details
#build ⇒ Object
28 29 30 31 32 |
# File 'lib/elasticquery/base.rb', line 28 def build @namespace = nil rules.each { |rule| instance_exec @params, &rule } query.to_hash end |
#filterable? ⇒ Boolean
19 20 21 |
# File 'lib/elasticquery/base.rb', line 19 def filterable? rules.any? end |