Module: HasFilter::ClassMethods

Defined in:
lib/has_filter.rb

Instance Method Summary collapse

Instance Method Details

#filter(filtering = nil, limit = 100) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/has_filter.rb', line 11

def filter(filtering = nil, limit = 100)
  conditions = filtering
  if @_filters.present?
    conditions = _valid_filters(conditions)
    return [] if conditions.empty?
  end

  conditions = _normalize_conditions(conditions)
  all(:conditions => _set_filters(conditions).flatten, :limit => limit)
end

#has_filter(allowed_fields = nil) ⇒ Object



7
8
9
# File 'lib/has_filter.rb', line 7

def has_filter(allowed_fields = nil)
  @_filters = *allowed_fields
end