attribute_normalizer
attribute_normalizer copied to clipboard
Better naming for old_#{attribute}
https://github.com/mdeering/attribute_normalizer/blob/master/lib/attribute_normalizer/model_inclusions.rb#L51-L57
alias_method "old_#{attribute}=", "#{attribute}="
define_method "#{attribute}=" do |value|
normalized_value = self.send(:"normalize_#{attribute}", value)
self.send("old_#{attribute}=", normalized_value)
end
old_ is not a good naming scheme.
Better use something like attribute_without_attribute_normalizer and attribute_with_attribute_normalizer
Some resources showing this naming convention:
- http://stackoverflow.com/questions/1034586/is-alias-method-chain-synonymous-with-alias-method
- http://apidock.com/rails/Module/alias_method_chain
- http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/
Agree with this. Would gladly accept a pull request making these changes.