<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1 @@
-0.3.5
+0.3.5
\ No newline at end of file</diff>
      <filename>VERSION</filename>
    </modified>
    <modified>
      <diff>@@ -9,11 +9,7 @@ module MongoMapper
       def build(opts={})
         owner = @owner
         child = @association.klass.new(opts)
-        child.class_eval do
-          define_method(owner.class.name.underscore) do
-            owner
-          end
-        end
+        assign_parent_reference(child)
         child._parent_document = owner
         self &lt;&lt; child
         child
@@ -26,14 +22,7 @@ module MongoMapper
         when String
           if load_target
             child = @target.detect {|item| item.id == opts}
-            if child
-              owner = @owner
-              child.class_eval do
-                define_method(owner.class.name.underscore) do
-                  owner
-                end
-              end
-            end
+            assign_parent_reference(child)
             child
           end
         end
@@ -54,9 +43,25 @@ module MongoMapper
       protected
         def find_target
           (@_values || []).map do |e|
-            @association.klass.new(e)
+            child = @association.klass.new(e)
+            assign_parent_reference(child)
+            child
           end
         end
+        
+      private
+      
+        def assign_parent_reference(child)
+          return unless child &amp;&amp; @owner
+          return if @owner.class.name.blank?
+          owner = @owner
+          child.class_eval do
+            define_method(owner.class.name.underscore) do
+              owner
+            end
+          end
+        end
+      
     end
   end
 end</diff>
      <filename>lib/mongomapper/associations/many_embedded_proxy.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3e4e26760d66887227193afa75de5fe7c2eef0ad</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/andrewtimberlake/mongomapper/commit/15ca223cc497c46d7e32cdcee51f4c1ce7f3631c</url>
  <id>15ca223cc497c46d7e32cdcee51f4c1ce7f3631c</id>
  <committed-date>2009-10-02T06:28:47-07:00</committed-date>
  <authored-date>2009-10-02T06:28:47-07:00</authored-date>
  <message>Adding parent reference to child embedded docs

Conflicts:

	VERSION
	mongomapper.gemspec</message>
  <tree>0c591f99baccfa85bc010e564b49c68b746f37c5</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
