Sha256: d111bdf46f82b5f9469de6ed203118bb8c805df1d7d7f14d00b1664862e4bf0e
Contents?: true
Size: 778 Bytes
Versions: 5
Compression:
Stored size: 778 Bytes
Contents
module Trestle module Search module Resource extend ActiveSupport::Concern included do # Include custom #collection method on Resource instance prepend Collection # Include custom #collection method on Resource class singleton_class.send(:prepend, Collection) end module Collection def collection(params={}) if searchable? query = params[:q].presence search(query, params) || super else super end end def search(query, params={}) adapter.search(query, params) end end module ClassMethods def searchable? adapter.respond_to?(:search) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems