<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -287,14 +287,21 @@ module DataMapper
 
     # Reloads association and all child association
     #
+    # This is accomplished by resetting the Resource key to it's
+    # original value, and then removing all the ivars for properties
+    # and relationships.  On the next access of those ivars, the
+    # resource will eager load what it needs.  While this is more of
+    # a lazy reload, it should result is more consistent behavior
+    # since no cached results will remain from the initial load.
+    #
     # @return [Resource]
     #   the receiver, the current Resource instance
     #
     # @api public
     def reload
-      if saved?
-        eager_load(fields)
-        child_collections.each { |children| children.reload }
+      if key
+        reset_key
+        clear_subjects
       end
 
       self
@@ -670,6 +677,33 @@ module DataMapper
       end
     end
 
+    # Reset the key to the original value
+    #
+    # @return [undefined]
+    #
+    # @api private
+    def reset_key
+      properties.key.zip(key) do |property, value|
+        property.set!(self, value)
+        original_attributes.delete(property)
+      end
+    end
+
+    # Remove all the ivars for properties and relationships
+    #
+    # @return [undefined]
+    #
+    # @api private
+    def clear_subjects
+      model_properties = properties
+
+      (model_properties - model_properties.key | relationships.values).each do |subject|
+        next unless subject.loaded?(self)
+        remove_instance_variable(subject.instance_variable_name)
+        original_attributes.delete(subject)
+      end
+    end
+
     # Lazy loads attributes not yet loaded
     #
     # @param [Array&lt;Property&gt;] properties</diff>
      <filename>lib/dm-core/resource.rb</filename>
    </modified>
    <modified>
      <diff>@@ -282,10 +282,12 @@ describe DataMapper::Property do
     # (since original value is set, property is no longer dirty)
     describe '#set_original_value' do
       before :all do
-        @image = Image.create(:md5hash     =&gt; '5268f0f3f452844c79843e820f998869',
-                              :title       =&gt; 'Rome at the sunset',
-                              :description =&gt; 'Just wow')
-        @image.reload
+        @image = Image.create(
+          :md5hash     =&gt; '5268f0f3f452844c79843e820f998869',
+          :title       =&gt; 'Rome at the sunset',
+          :description =&gt; 'Just wow'
+        )
+
         @property = Image.properties[:title]
       end
 
@@ -315,10 +317,12 @@ describe DataMapper::Property do
       before :all do
         # keep in mind we must run these examples with a
         # saved model instance
-        @image = Image.create(:md5hash     =&gt; '5268f0f3f452844c79843e820f998869',
-                              :title       =&gt; 'Rome at the sunset',
-                              :description =&gt; 'Just wow')
-        @image.reload
+        @image = Image.create(
+          :md5hash     =&gt; '5268f0f3f452844c79843e820f998869',
+          :title       =&gt; 'Rome at the sunset',
+          :description =&gt; 'Just wow'
+        )
+
         @property = Image.properties[:title]
       end
 </diff>
      <filename>spec/public/property_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -555,57 +555,81 @@ share_examples_for 'A public Resource' do
   it { @user.should respond_to(:reload) }
 
   describe '#reload' do
-    describe 'on a resource' do
-      before :all do
-        rescue_if @skip do
-          @user.name = 'dkubb'
-          @user.description = 'test'
-          @user.reload
-        end
+    before do
+      # reset the user for each spec
+      rescue_if(@skip) do
+        @user.update(:name =&gt; 'dbussink', :age =&gt; 25, :description =&gt; 'Test')
+      end
+    end
+
+    subject { rescue_if(@skip) { @user.reload } }
+
+    describe 'on a resource not persisted' do
+      before do
+        @user.attributes = { :description =&gt; 'Changed' }
       end
 
-      it { @user.name.should eql('dbussink') }
+      it { should be_kind_of(DataMapper::Resource) }
+
+      it { should equal(@user) }
 
-      it 'should also reload previously loaded attributes' do
-        @user.attribute_loaded?(:description).should be_true
+      it { should be_clean }
+
+      it 'reset the changed attributes' do
+        method(:subject).should change(@user, :description).from('Changed').to('Test')
+      end
+    end
+
+    describe 'on a resource where the key is changed, but not persisted' do
+      before do
+        @user.attributes = { :name =&gt; 'dkubb' }
+      end
+
+      it { should be_kind_of(DataMapper::Resource) }
+
+      it { should equal(@user) }
+
+      it { should be_clean }
+
+      it 'reset the changed attributes' do
+        method(:subject).should change(@user, :name).from('dkubb').to('dbussink')
       end
     end
 
     describe 'on a resource that is changed outside another resource' do
-      before :all do
+      before do
         rescue_if @skip do
-          @user2 = @user.dup
-          @user2.description = 'Changed'
-          @user2.save
-          @user.reload
+          @user.dup.update(:description =&gt; 'Changed')
         end
       end
 
+      it { should be_kind_of(DataMapper::Resource) }
+
+      it { should equal(@user) }
+
+      it { should be_clean }
+
       it 'should reload the resource from the data store' do
-        @user.description.should eql('Changed')
+        method(:subject).should change(@user, :description).from('Test').to('Changed')
       end
     end
 
     describe 'on an anonymous resource' do
-      before :all do
+      before do
         rescue_if @skip do
-          @user = @user.model.first(:fields =&gt; [ :description ])
+          @user = @user.class.first(:fields =&gt; [ :description ])
           @user.description.should == 'Test'
-
-          @return = @user.reload
         end
       end
 
-      it 'should return a Resource' do
-        @return.should be_kind_of(DataMapper::Resource)
-      end
+      it { should be_kind_of(DataMapper::Resource) }
 
-      it 'should return the expected value' do
-        @return.should equal(@user)
-      end
+      it { should equal(@user) }
+
+      it { should be_clean }
 
-      it 'should not reload any other attributes' do
-        @user.attributes.should == { :description =&gt; 'Test' }
+      it 'should not reload any attributes' do
+        method(:subject).should_not change(@user, :attributes)
       end
     end
   end</diff>
      <filename>spec/public/shared/resource_shared_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>337f9d050f4c24acc95861188dfc2e547e3161f0</id>
    </parent>
  </parents>
  <author>
    <name>Dan Kubb</name>
    <email>dan.kubb@gmail.com</email>
  </author>
  <url>http://github.com/datamapper/dm-core/commit/6f574839b0f1a1e4e0d3e569e75d2e109919b5a2</url>
  <id>6f574839b0f1a1e4e0d3e569e75d2e109919b5a2</id>
  <committed-date>2009-11-06T23:04:52-08:00</committed-date>
  <authored-date>2009-11-06T23:04:52-08:00</authored-date>
  <message>Updated Resource#reload to clear non-key property and relationship ivars

* This has the effect of restoring a Resource to a pristine state where
  the only thing set is the key.  If the key was modified it restores
  it to it's original values.  On the first access to an unloaded
  property or resource the Resource will lazy load the values.  This
  has the same outcome as explicitly reloading the Resource, but
  does not require eager loading.
* Updated Resource#reload specs to pass with heckle</message>
  <tree>0a2c97798d076a33673d3b7166de5f7bf7ac4de8</tree>
  <committer>
    <name>Dan Kubb</name>
    <email>dan.kubb@gmail.com</email>
  </committer>
</commit>
