mongodb/bson-ruby — pull request #15 by mdsell (2014-02-16 15:08:05+00:00)
Title: Return Time::BSON_TYPE for Date and DateTime instances

This pull request allows Date and DateTime objects to be serialised as BSON when inside Hash and Array objects.

Currently, the following produces a NoMethodError:

```
{ date: Date.today }.to_bson
```

Instances of Date (and by extension DateTime) do not respond to `bson_type`, but do convert to Time objects when serialised directly. Mapping these instances as part of an Array or Hash does require these to respond to `bson_type`, and so to fix this, I've defined a `bson_type` method on Date (inherited by DateTime) which returns the value of `Time::BSON_TYPE`.

This is, as you might imagine, largely an itch-scratching PR. If this logic is better suited to my application, let me know!