lib/trestle/search/resource.rb in trestle-search-0.3.0 vs lib/trestle/search/resource.rb in trestle-search-0.4.0
- old
+ new
@@ -10,15 +10,19 @@
# Include custom #collection method on Resource class
singleton_class.send(:prepend, Collection)
end
module Collection
- def collection(params)
+ def collection(params={})
if searchable?
- adapter.search(params[:q].presence, params)
+ search(params[:q].presence, params)
else
super
end
+ end
+
+ def search(query, params={})
+ adapter.search(query, params)
end
end
module ClassMethods
def searchable?