Module: Napa::FilterByHash::ClassMethods
- Defined in:
- lib/napa/active_record_extensions/filter_by_hash.rb
Instance Method Summary collapse
Instance Method Details
#filter(search_hash = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/napa/active_record_extensions/filter_by_hash.rb', line 5 def filter(search_hash = {}) # pass an empty where clause to force results to be a relation that will be lazy evaluated results = where({}) search_hash.each do |k, v| results = results.where(k => v) end results end |