From c8f6b184c84ce643f13d647eadcc0756dca8c70b Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Sun, 13 Dec 2009 08:44:40 -0500 Subject: [PATCH] Updating rdoc on has_many_related --- lib/mongoid/associations/has_many_related.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/mongoid/associations/has_many_related.rb b/lib/mongoid/associations/has_many_related.rb index 187e8cc3fb..c6e00f0316 100644 --- a/lib/mongoid/associations/has_many_related.rb +++ b/lib/mongoid/associations/has_many_related.rb @@ -5,14 +5,23 @@ class HasManyRelated < DelegateClass(Array) #:nodoc: attr_reader :klass - # Instantiate a new associated object and add it to the relationship. + # Builds a new Document and adds it to the association collection. The + # document created will be of the same class as the others in the + # association, and the attributes will be passed into the constructor. + # + # Returns the newly created object. def build(attributes) object = @klass.instantiate(attributes.merge(@foreign_key => @parent.id)) @documents << object object end - # Create a new object for the association, save it, and add it. + # Creates a new Document and adds it to the association collection. The + # document created will be of the same class as the others in the + # association, and the attributes will be passed into the constructor and + # the new object will then be saved. + # + # Returns the newly created object. def create(attributes) object = build(attributes) object.save