Module: ActsAsFilterable
- Defined in:
- lib/acts_as_filterable/base.rb,
lib/acts_as_filterable.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ActiveRecordExt
Constant Summary collapse
- Filters =
This flyweight represents all of the filters that we can run on attributes. Each filter should modify the attribute value in place an not create new strings. The following filters exist:
-
digits - strip any numeric characters out.
-
lowercase - make all character values lowercase.
-
uppercase - make all character values uppercase.
-
whitespace - strip any non-important whitespace out of the value (tabs and newlines).
-
returning Hash.new([]) do |f| f[:digits] = lambda { |attr| attr.gsub!(/[^\d]*/, "") } f[:lowercase] = lambda { |attr| attr.downcase! } f[:uppercase] = lambda { |attr| attr.upcase! } f[:whitespace] = lambda { |attr| attr.gsub!(/\s+/, " "); attr.strip! } end.freeze