mongoid/mongoid — pull request #2720 by goshakkk (2013-01-20 11:22:49+00:00)
Title: Aggregation on contextual objects

Currently, aggregation is only available on the collection, and query has to be added manually:

```ruby
selector = Band.where(name: "Depeche Mode").query.selector
Band.collection.aggregate([{"$match"=> selector}, ...])
```

With this PR, `#aggregation` will be available on queries and will take selector into account:

```ruby
Band.where(name: "Depeche Mode").aggregate({"$sort" => { "likes" => -1}})
```

(Having to write aggregate pipeline manually isn't that awesome though, I might try to implement a nicer DSL for that later.)