Hi Iain,
I was actually mistaken in my first reply when I said that the lambda
was required. You can actually just do :default => Location.new, and
the Location will be cloned when the Project is instantiated.
class Project < MongoModel::Document
property :location, Location, :default => Location.new
end
The reason MongoModel works this way is for consistency with other
property types. Most property values (e.g. String, Integer, etc) will
default to nil so I wanted to maintain this with embedded documents.
In your app or someone else's, a Project may not require a Location
and hence it would be nil.
Thanks,
Sam