drapergem/draper — pull request #408 by haines (2013-01-07 12:37:46+00:00)
Title: Infer collection decorator

As @jerodsanto mentioned on #401, it would be nice if calling `decorate` on an `Event` scope would return an `EventsDecorator` if that were defined:

```ruby
Event.upcoming.decorate

# current behaviour:
# => #

# desired behaviour:
# => #
```

I've implemented this by changing `Decorator.decorate_collection` to infer the collection decorator class where possible. This means that the following cases remain consistent:

```ruby
EventDecorator.decorate_collection(Event.upcoming)
# => #

Event.upcoming.decorate
# => #
```

In fact, the latter case actually just calls the former ([Decoratable.decorate](https://github.com/drapergem/draper/blob/master/lib/draper/decoratable.rb#L29-L31)).