<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -310,7 +310,7 @@ module DataMapper
               @loaded_set.reload!(:fields =&gt; self.class.properties(self.class.repository.name).lazy_load_context(#{name.inspect}))
             end
           end
-          #{custom? ? &quot;#{@type.inspect}.load(#{@instance_variable_name})&quot; : @instance_variable_name}
+          #{custom? ? &quot;#{@type.inspect}.load(#{@instance_variable_name}, self.class.properties(self.class.repository.name)[#{name.inspect}])&quot; : @instance_variable_name}
         end
       EOS
     rescue SyntaxError
@@ -324,7 +324,7 @@ module DataMapper
         def #{name}=(value)
           #{lock? ? &quot;@shadow_#{name} = #{@instance_variable_name}&quot; : ''}
           dirty_attributes &lt;&lt; self.class.properties(repository.name)[#{name.inspect}]
-          #{@instance_variable_name} = #{custom? ? &quot;#{@type.inspect}.dump(value)&quot; : 'value'}
+          #{@instance_variable_name} = #{custom? ? &quot;#{@type.inspect}.dump(value, self.class.properties(self.class.repository.name)[#{name.inspect}])&quot; : 'value'}
         end
       EOS
     rescue SyntaxError</diff>
      <filename>lib/data_mapper/property.rb</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@ module DataMapper
       end
 
       value = instance_variable_get(ivar_name)
-      property.custom? ? property.type.load(value) : value
+      property.custom? ? property.type.load(value, property) : value
     end
 
     def []=(name, value)
@@ -62,7 +62,7 @@ module DataMapper
       end
 
       dirty_attributes &lt;&lt; property
-      instance_variable_set(ivar_name, property.custom? ? property.type.dump(value) : value)
+      instance_variable_set(ivar_name, property.custom? ? property.type.dump(value, property) : value)
     end
 
     def repository</diff>
      <filename>lib/data_mapper/resource.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,7 +27,7 @@ module DataMapper
   #     primitive String
   #     size 10
   #
-  #     def self.dump(value)
+  #     def self.dump(value, property)
   #       &lt;work some magic&gt;
   #     end
   #
@@ -129,7 +129,7 @@ module DataMapper
     #
     #
     # @public
-    def self.dump(value)
+    def self.dump(value, property)
       value
     end
 
@@ -144,7 +144,7 @@ module DataMapper
     #
     #
     # @public
-    def self.load(value)
+    def self.load(value, property)
       value
     end
 </diff>
      <filename>lib/data_mapper/type.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module DataMapper
       size 65535
       lazy true
 
-      def self.load(value)
+      def self.load(value, property)
         case value
         when String then FasterCSV.parse(value)
         when Array then value
@@ -13,7 +13,7 @@ module DataMapper
         end
       end
 
-      def self.dump(value)
+      def self.dump(value, property)
         case value
         when Array then
           FasterCSV.generate do |csv|</diff>
      <filename>lib/data_mapper/types/csv.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ module DataMapper
       size 65535
       lazy true
 
-      def self.load(value)
+      def self.load(value, property)
         if value.nil?
           nil
         elsif value.is_a?(String)
@@ -17,7 +17,7 @@ module DataMapper
         end
       end
 
-      def self.dump(value)
+      def self.dump(value, property)
         if value.nil?
           nil
         elsif value.is_a?(String) &amp;&amp; value =~ /^---/</diff>
      <filename>lib/data_mapper/types/yaml.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,14 +15,35 @@ describe DataMapper::Type do
       primitive String
       size 10
 
-      def self.load(value)
+      def self.load(value, property)
         value.reverse
       end
 
-      def self.dump(value)
+      def self.dump(value, property)
         value.reverse
       end
     end
+    
+    class TestResource
+      include DataMapper::Resource
+    end
+    
+    class TestType3 &lt; DataMapper::Type
+      primitive String
+      size 10
+      attr_accessor :property, :value
+
+      def self.load(value, property)
+        type = self.new
+        type.property = property
+        type.value    = value
+        type
+      end
+
+      def self.dump(value, property)
+        value.value
+      end
+    end
   end
 
   it &quot;should have the same PROPERTY_OPTIONS aray as DataMapper::Property&quot; do
@@ -48,19 +69,42 @@ describe DataMapper::Type do
   end
 
   it &quot;should pass through the value if load wasn't overriden&quot; do
-    TestType.load(&quot;test&quot;).should == &quot;test&quot;
+    TestType.load(&quot;test&quot;, nil).should == &quot;test&quot;
   end
 
   it &quot;should pass through the value if dump wasn't overriden&quot; do
-    TestType.dump(&quot;test&quot;).should == &quot;test&quot;
+    TestType.dump(&quot;test&quot;, nil).should == &quot;test&quot;
   end
 
   it &quot;should not raise NotImplmenetedException if load was overriden&quot; do
-    TestType2.dump(&quot;helo&quot;).should == &quot;oleh&quot;
+    TestType2.dump(&quot;helo&quot;, nil).should == &quot;oleh&quot;
   end
 
   it &quot;should not raise NotImplmenetedException if dump was overriden&quot; do
-    TestType2.load(&quot;oleh&quot;).should == &quot;helo&quot;
+    TestType2.load(&quot;oleh&quot;, nil).should == &quot;helo&quot;
+  end
+
+  describe &quot;using a custom type&quot; do
+    before do
+      @property = DataMapper::Property.new TestResource, :name, TestType3, {}
+    end
+    
+    it &quot;should return a object of the same type&quot; do
+      TestType3.load(&quot;helo&quot;, @property).class.should == TestType3
+    end
+    
+    it &quot;should contain the property&quot; do
+      TestType3.load(&quot;helo&quot;, @property).property.should == @property
+    end
+    
+    it &quot;should contain the value&quot; do
+      TestType3.load(&quot;helo&quot;, @property).value.should == &quot;helo&quot;
+    end
+    
+    it &quot;should return the value&quot; do
+      obj = TestType3.load(&quot;helo&quot;, @property)
+      TestType3.dump(obj, @property).should == &quot;helo&quot;
+    end
   end
 
   describe &quot;using def Type&quot; do</diff>
      <filename>spec/unit/type_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0f38788ebd9dfa4395b021255b13ee7b55a58cb5</id>
    </parent>
  </parents>
  <author>
    <name>Ken Robertson</name>
    <email>ken@explosivethoughts.com</email>
  </author>
  <url>http://github.com/sam/dm-core/commit/0e283f878c5bd0a3cb241a553ba2c967e17b3e91</url>
  <id>0e283f878c5bd0a3cb241a553ba2c967e17b3e91</id>
  <committed-date>2008-04-10T12:59:01-07:00</committed-date>
  <authored-date>2008-04-10T12:59:01-07:00</authored-date>
  <message>Added support to pass property information own to custom types in the dump/load</message>
  <tree>e564126ab9eb0e762353cc92333cb00e87a9ccfe</tree>
  <committer>
    <name>Ken Robertson</name>
    <email>ken@explosivethoughts.com</email>
  </committer>
</commit>
