Module: NormalizeAttributes::Callbacks::ClassMethods

Defined in:
lib/normalize_attributes/callbacks.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
73
74
75
# File 'lib/normalize_attributes/callbacks.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