Module: HasNormalizedAttributes
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/version.rb,
lib/has_normalized_attributes.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.6"- ZIPCODE =
CONSTANT
/[-.\s)(,]/- PHONE =
/[-.\s)(,]|(^0)/- SSN =
/[-.\s)(,]/- TAXID =
/[-.\s)(,]/- DOLLAR =
/[$,\s]/- NUMBER =
/[,\s]/- PERCENT =
/[%,\s]/- SPACES =
/\s/
Class Method Summary collapse
-
.normalizations(*args) ⇒ Object
instance methods.
Class Method Details
.normalizations(*args) ⇒ Object
instance methods
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/has_normalized_attributes.rb', line 34 def self.normalizations(*args) args.each do |arg| define_method "normalize_#{arg}" do if arg == :strip self ? self.strip! : self else reg_exp = HasNormalizedAttributes.const_get(arg.upcase) self && is_a?(String) && match(reg_exp) ? gsub!(reg_exp,'') : self end end end end |