Module: Filterable
- Defined in:
- lib/filtrate/filterable.rb
Instance Method Summary collapse
Instance Method Details
#filtered(opts) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/filtrate/filterable.rb', line 2 def filtered(opts) opts ||= {} scope = self.scoped opts.each do |attr, val| if val.kind_of? Hash scope = Filtrate::Filter.new(scope, attr, val).to_scope if val['from'].present? && val['to'].present? else scope = Filtrate::Filter.new(scope, attr, val).to_scope if val.present? end end scope end |