I encountered a pattern today that I would like to share:
There is no justification to write such a code in ruby (or in any language)
ActiveRecord 3 with ARel does not defer class singleton methods from scopes and in my opinion they are more readable.
We could write the same functionality with:
Now, the path is short to go to:
I like it – do you?
We didn’t only clean the code.
We did much more – every new status in the STATUS list will effortlessly represented with a matching method.
For instance :curator key which had no scope in the original version is now represented with the User.curator method.
DRY is not (just) about aesthetics. DRY is about maintainability and simplicity.