Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
I think that the chain of decorators applied to a model should be a method on
Decoratornot a procedural function in theUtilsnamespace.I have called it
applied_decorators, and addeddecorated_with?to test if a given decorator is in the chain. This means we get the RSpec matcher for free:A common interface between
DecoratorandDecoratableis useful so that we can apply this test to undecorated models, so I added these methods toDecoratabletoo (returning[]andfalserespectively, as you might expect).While I was at it I added a
decorated?method that returns false on models and true on decorators. Potentially useful for people who are inadvertently double-decorating.And following that thought process I prevented
Decoratorfrom proxying#decorateto the model, which means that we can safely dodecorator = possibly_decorated_object.decorate. Previously, we hadWhat do you reckon?