Class: Mks::Maintenance::FilterUtil
- Inherits:
-
Object
- Object
- Mks::Maintenance::FilterUtil
- Defined in:
- app/utils/mks/maintenance/filter_util.rb
Instance Method Summary collapse
Instance Method Details
#get_filtered_data(type, filters) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/utils/mks/maintenance/filter_util.rb', line 4 def get_filtered_data(type, filters) positive = {} negative = {} obj = type.constantize filters.each { |f| if f[:cond] == 'P' positive[f[:key]] = f[:value] else negative[f[:key]] = f[:value] end } result = obj.where(positive).where.not(negative) end |