Module: NormalizeAttributes::ActiveRecord::ClassMethods

Defined in:
lib/normalize_attributes/active_record.rb

Instance Method Summary collapse

Instance Method Details

#normalize(*args, &block) ⇒ Object Also known as: normalize_attributes, normalize_attribute, normalize_attr, normalize_attrs



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/normalize_attributes/active_record.rb', line 60

def normalize(*args, &block)
  self.normalize_options ||= {}
  options = args.extract_options!

  args.each do |attr_name|
    attr_name = attr_name.to_sym

    normalize_options.tap do |o|
      o[attr_name] ||= []
      o[attr_name] << [[block, options[:with]].flatten.compact, options.except(:with)]
    end
  end
end