Method: Mebla::Search#initialize
- Defined in:
- lib/mebla/search.rb
#initialize(query_string = "", type_names = []) ⇒ Search
Creates a new Search object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mebla/search.rb', line 42 def initialize(query_string = "", type_names = []) # Convert type names from string or symbol to array type_names = case true when type_names.is_a?(Symbol), type_names.is_a?(String) [type_names] when type_names.is_a?(Array) && !type_names.empty? type_names.collect{|name| name.to_s} else [] end @slingshot_search = Slingshot::Search::Search.new(Mebla.context.slingshot_index_name, {}) # Add a type filter to return only certain types unless type_names.empty? only(:_type => type_names) end unless query_string.blank? query(query_string) end end |