mdeering / attribute_normalizer

Adds the ability to normalize attributes cleanly with code blocks and predefined normalizers
MIT License
475 stars 53 forks source link

removing a normalization after it's already been added. #83

Open KevinVerre opened 6 years ago

KevinVerre commented 6 years ago

Great gem, but I have some questions that aren't super obvious from the ReadMe:

If I call normalize_attribute a second time on the same attribute, does it remove the first normalization or add to it?

normalize_attribute(:title, with: [:blank])
normalize_attribute(:title, with: [:strip]) # does this remove :blank ?
# or is it the same as doing this: normalize_attribute(:title, with: [:blank, :strip]) 

In my brief testing, it DID remove the previous one.

Second question, is there a remove a normalization after it has already been added?

For example, if a parent class has a normalization you don't want in the child class. normalize_attribute(:title, with: [:blank, :strip]) # how to remove :strip ?