Module: HasNormalizedAttributes::CoreExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/has_normalized_attributes.rb
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 |