Module: Refinuri::Query

Included in:
Refinuri
Defined in:
lib/refinuri/query.rb

Instance Method Summary collapse

Instance Method Details

#filtered(filterset) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/refinuri/query.rb', line 3

def filtered(filterset)
  if filterset.is_a?(Refinuri::Base::FilterSet)
    filtered_self = self.scoped

    filterset.filters.each do |name,filter_obj|
      filtered_self = filtered_self.where(filter_obj.to_db)
    end        

    return filtered_self.scoped
  else
    return self
  end
end