drapergem/draper — pull request #499 by urbanautomaton (2013-03-13 16:05:16+00:00)
Title: Decorator namespace option (second attempt)

Hi,

Since the namespace feature has been reverted, I've taken a second stab at it here. As @haines mentions in #480, the original changes did end up touching more of the codebase than ought to have been necessary.

This was partly due to the regular checking of valid options keys in the existing codebase, combined with the way the different entry-points support different combinations of options. Because this was hard-coded at each point ([this](https://github.com/urbanautomaton/draper/blob/b1d66ca15c076e7ddd0f13230d4d25b099395c70%5E/lib/draper/decorated_association.rb#L6-L15) is an example of what I mean), namespace options handling ended up in a lot of places it didn't belong.

This time I've approached the problem in two parts:

1. Set constants defining valid options, and use these to validate and slice where necessary
2. Add the namespace option.

I've kept the options-handling changes separate from the addition of the namespace option for easier review. As you can see, with the options constants available, the changes necessary to actually add the namespace option are much more localised - the only places the namespace option is actually referred to (outside tests and documentation) are the definition of `Decoratable::VALID_OPTIONS`, and the `Decoratable.decorator_class` and `Decorator.collection_decorator_class` methods.

Any thoughts and feedback much appreciated...

Cheers,
Simon