Module: Charwidth::ActiveModel::ClassMethods

Defined in:
lib/charwidth/active_model.rb

Instance Method Summary collapse

Instance Method Details

#normalize_charwidth(*attribute_names) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/charwidth/active_model.rb', line 6

def normalize_charwidth(*attribute_names)
  m = Module.new do
    attribute_names.each do |attribute|
      define_method "#{attribute}=" do |v|
        super(v.nil? ? nil : Charwidth.normalize(v.to_s))
      end
    end
  end
  prepend m
end