class Elasticsearch::DSL::Search::Filter
Wraps the `filter` part of a search definition, aggregation, etc
@see www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html
Public Class Methods
new(*args, &block)
click to toggle source
# File lib/elasticsearch/dsl/search/filter.rb, line 31 def initialize(*args, &block) @block = block end
Public Instance Methods
call()
click to toggle source
Evaluates any block passed to the query
@return [self]
# File lib/elasticsearch/dsl/search/filter.rb, line 54 def call @block.arity < 1 ? self.instance_eval(&@block) : @block.call(self) if @block self end
method_missing(name, *args, &block)
click to toggle source
Looks up the corresponding class for a method being invoked, and initializes it
@raise [NoMethodError] When the corresponding class cannot be found
Calls superclass method
# File lib/elasticsearch/dsl/search/filter.rb, line 39 def method_missing(name, *args, &block) klass = Utils.__camelize(name) if Filters.const_defined? klass @value = Filters.const_get(klass).new *args, &block elsif @block @block.binding.eval('self').send(name, *args, &block) else super end end
to_hash(options={})
click to toggle source
Converts the query definition to a Hash
@return [Hash]
# File lib/elasticsearch/dsl/search/filter.rb, line 63 def to_hash(options={}) call if @value @value.to_hash else {} end end