drapergem/draper — pull request #331 by haines (2012-11-08 01:45:15+00:00)
Title: Refactor Decorator.decorate

Fixes #328.

The major changes are

* No more `Decorator#context`. There is no reason to have a specific option to store options (Optionception?!), because the options themselves are stored in the decorator. You can do `Product.decorate(role: :admin)`, so why bother with `Product.decorate(context: {role: :admin})`? (This doesn't remove the possibility of using a `:context` option if that's your thing, it just removes any special treatment on our end).

* `Decoratable#decorate` is no longer memoized, because it was ignoring options. Removed the `decorator` alias (since that implies a single object), and the block syntax. If people feel strongly about the blocks we could reintroduce it as a separate method, but I don't think it belongs in `decorate`.

* The main one: Split up `Decorator.decorate` into `decorate` and `decorate_collection`. `decorate` is now just an alias for `new`, and we no longer need to sniff for `each` methods, which was troublesome with things like `Struct`.