module Croods::Resource::Filters
Public Instance Methods
apply_filters(scope, params)
click to toggle source
# File lib/croods/resource/filters.rb, line 16 def apply_filters(scope, params) filters.each do |attribute| unless model.has_attribute?(attribute.name) attribute.name = "#{attribute.name}_id" end value = params[attribute.name] next unless value scope = scope.where(attribute.name => value) end scope end
filter_by(name, optional: nil)
click to toggle source
# File lib/croods/resource/filters.rb, line 6 def filter_by(name, optional: nil) filters << Croods::Attribute.new( name, :string, null: optional ) end
filters()
click to toggle source
# File lib/croods/resource/filters.rb, line 12 def filters @filters ||= [] end