lib/sanitizable/macro.rb
# Defines one or multiple columns that should be sanitized. The method used
# for sanitizing can be defined via the :with key and can either contain the name
# of any method that is implemented on the particular class or a custom Proc.
# Additionally, an Array of Symbols or Procs can be speficied. Alternatively a block
# can be supplied as sanitizer.
#
# -----
#
# === Example:
#   class User < ActiveRecord::Base   
#     sanitizes :first_name, :last_name, with: :strip
#     sanitizes :email, with: [:strip, :downcase]
#     sanitizes :biography, with: ->(biography) { biography.squish }
#     sanitizes :username do |username|
#       # strip leading "@" characters as used in Twitter usernames
#       username.strip.downcase.sub(/\A@/, '')
#     end
#   end
Defines one or multiple columns that should be sanitized. The method used
for sanitizing can be defined via the :with key and can either contain the name
of any method that is implemented on the particular class or a custom Proc.
Additionally, an Array of Symbols or Procs can be speficied. Alternatively a block
can be supplied as sanitizer.




Defines one or multiple columns that should be sanitized . The method used for sanitizing can be defined via the : with key and can either contain the name of any method that is implemented on the particular class or a custom Proc . Additionally an Array of Symbols or Procs can be speficied . Alternatively a block can be supplied as sanitizer .
def skip_sanitization_of(*attribute_names)
      options = attribute_names.extract_options!.assert_valid_keys(:on)
      if self.include?(Model)
        attribute_names = attribute_names.map(&:to_s)
        context = options[:on]
        sanitizable_attributes.delete_if do |attribute|
          attribute_names.include?(attribute.name) and context == attribute.context
        end
      end
    end
def skip_sanitization_of ( * attribute_names ) options = attribute_names . extract_options! . assert_valid_keys ( :on ) if self . include? ( Model ) attribute_names = attribute_names . map ( & :to_s ) context = options [ :on ] sanitizable_attributes . delete_if do | attribute | attribute_names . include? ( attribute . name ) and context == attribute . context end end end
Defines one or multiple columns that should be sanitized.
Defines one or multiple columns that should be sanitized .
attribute_names
<not_specific>