mongoid/mongoid — pull request #2731 by wyattisimo (2013-01-22 07:48:19+00:00)
Title: Make fields of type Array or Hash initialize to empty Array or Hash (instead of nil)

I found this to be very useful, but I don't know if it's in line with your overall strategy.

**Explanation:** When using relations, a "many" reference (e.g.: has_many, embeds_many) initializes as an empty array, which allows you to use array-specific methods (e.g.: `Array#<<`) with no worries. This behavior is nice. When defining a regular field of type Array, it initializes as nil, so if you're not sure whether the array already has elements in it, then you can't use array-specific methods without first testing whether it actually *is* an array. A similar argument applies to operating on fields of type Hash. This update just sets Array and Hash fields as "empty" instead of nil.