class ElasticsearchQuery::Filters
Public Class Methods
new( params )
click to toggle source
# File lib/elasticsearch_query/filters.rb, line 3 def initialize( params ) @params = params end
Public Instance Methods
to_hash()
click to toggle source
# File lib/elasticsearch_query/filters.rb, line 7 def to_hash if matches.length == 1 matches.first else { bool: { must: matches } } end end
Private Instance Methods
matches()
click to toggle source
# File lib/elasticsearch_query/filters.rb, line 17 def matches @filters ||= begin @params.fetch( :filter, {} ).each_with_object( [] ) do | ( field, value ), arr | arr << Filter.new( field, value ).to_hash end.compact end end