<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -28,13 +28,16 @@ module ActionORM
 
   module Core
     module ClassMethods
-      def supports?(obj)
-        !find_key(obj).nil?
-      end
 
       def for(obj)
+        return nil if obj.nil?
+        unless supports?(obj)
+          ActionORM.use :driver =&gt; ActionORM::Drivers::AbstractDriver, :for =&gt; obj.class
+        end
         driver = driver_registry[find_key(obj)]
         case driver
+        when :compliant
+          obj
         when NilClass
           obj
         else
@@ -52,7 +55,20 @@ module ActionORM
         ActionORM.register(options[:for], options[:driver])
       end
       
+      def find_key(obj)
+        return nil if obj.nil?
+        unless driver_key_cache.key?(obj.class)
+          driver_key_cache[obj.class] = driver_registry.keys.find {|k, v| obj.is_a? k }
+        end
+        driver_key_cache[obj.class]
+      end
+      
       protected
+      
+        def supports?(obj)
+          !find_key(obj).nil?
+        end
+      
         def driver_registry
           @_driver_registry ||= {}
         end
@@ -65,12 +81,6 @@ module ActionORM
           driver_registry[obj_class] = obj_driver_class
         end
         
-        def find_key(obj)
-          unless driver_key_cache.key?(obj.class)
-            driver_key_cache[obj.class] = driver_registry.keys.find {|k, v| obj.is_a? k }
-          end
-          driver_key_cache[obj.class]
-        end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>merb-actionorm/lib/merb-actionorm/action_orm/core.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,15 +30,27 @@ module ActionORM
       end
   
       def new_record?
-        model.new_record?
+        if !@model.respond_to?(:new_record?)
+          raise AbstractDriverMethod, &quot;#{@model.class} doesn't define a way to check if a new record is new or not!&quot;
+        else
+          @model.new_record?
+        end
       end
   
       def errors
-        raise AbstractDriverMethod
+        if !@model.respond_to?(:errors)
+          raise AbstractDriverMethod, &quot;#{@model.class} doesn't define a way to look up errors!&quot;
+        else
+          @model.errors
+        end
       end
   
       def valid?
-        model.valid?
+        if !@model.respond_to?(:valid?)
+          raise AbstractDriverMethod, &quot;#{@model.class} doesn't define a way to check if an instance is valid!&quot;
+        else
+          @model.valid?
+        end
       end
     end
   end</diff>
      <filename>merb-actionorm/lib/merb-actionorm/action_orm/drivers/abstract_driver.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,9 +3,6 @@ require File.dirname(__FILE__) + '/spec_helper'
 describe &quot;merb-actionorm&quot; do
   
    shared_examples_for &quot;a supported ORM&quot; do
-     it &quot;should support the orm&quot; do
-       ActionORM.supports?(@model_instance).should be_true
-     end
 
      it &quot;should know if a record is a new record or not&quot; do
        ActionORM.for(@model_instance).new_record?.should be_true
@@ -44,6 +41,12 @@ describe &quot;merb-actionorm&quot; do
       @model_instance.name = nil
       ActionORM.for(@model_instance).valid?.should be_false
     end
+    
+    it &quot;should have a list of errors on failed validation&quot; do
+      @model_instance.name = nil
+      ActionORM.for(@model_instance).valid?.should be_false
+      @model_instance.errors.class.should_not be_nil
+    end
   end
 
   # describe &quot;ActiveRecord ORM&quot; do
@@ -93,7 +96,7 @@ describe &quot;merb-actionorm&quot; do
     end
   end
   
-  describe &quot;FakeModel&quot; do
+  describe &quot;Compliant model&quot; do
     before(:all) do
       class FakeModel
         def valid?
@@ -103,23 +106,27 @@ describe &quot;merb-actionorm&quot; do
           true
         end
         def errors
-          FakeErrors.new(self)
+          {:name =&gt; &quot;can't be empty&quot;}
         end
         def to_s
           'fake_model'
         end
       end
-      ActionORM.use :driver =&gt; ActionORM::Drivers::AbstractDriver, :for =&gt; FakeModel
+      ActionORM.use :driver =&gt; :compliant, :for =&gt; FakeModel
       @model_instance = FakeModel.new
     end
-    
-    it &quot;should support the orm&quot; do
-      ActionORM.supports?(@model_instance).should be_true
-    end
 
     it &quot;should know if a record is a new record or not&quot; do
       ActionORM.for(@model_instance).new_record?.should be_true
     end
+    
+    it &quot;should know if a record is valid&quot; do
+      ActionORM.for(@model_instance).new_record?.should be_true
+    end
+    
+    it &quot;should know if a record is valid&quot; do
+      ActionORM.for(@model_instance).errors.should be_true
+    end
   end
   
 end
\ No newline at end of file</diff>
      <filename>merb-actionorm/spec/merb-actionorm_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -131,7 +131,8 @@ module Merb::Helpers::Form::Builder
       attrs[:method] = :post unless attrs[:method] == :get
       # Use a fake PUT if the object is not new, otherwise use the method
       # passed in. Defaults to :post if no method is set.
-      method ||= (ActionORM.supports?(@obj) &amp;&amp; !ActionORM.for(@obj).new_record?) || (@obj.respond_to?(:new?) &amp;&amp; !@obj.new?) ? :put : :post
+      standardized_object = ActionORM.for(@obj)
+      method ||=  (!standardized_object.nil? &amp;&amp; standardized_object.new_record?) || (@obj.respond_to?(:new?) &amp;&amp; @obj.new?) ? :post : :put
 
       attrs[:enctype] = &quot;multipart/form-data&quot; if attrs.delete(:multipart) || @multipart
 </diff>
      <filename>merb-helpers/lib/merb-helpers/form/builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,3 +23,5 @@ class FakeDMModel
   end
   alias bat bat?
 end
+
+ActionORM.use :driver =&gt; :compliant, :for =&gt; FakeDMModel
\ No newline at end of file</diff>
      <filename>merb-helpers/spec/fixture/app/models/fake_dm_model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -56,4 +56,4 @@ class FakeModel
   end
 end
 
-ActionORM.use :driver =&gt; ActionORM::Drivers::AbstractDriver, :for =&gt; FakeModel
\ No newline at end of file
+ActionORM.use :driver =&gt; :compliant, :for =&gt; FakeModel
\ No newline at end of file</diff>
      <filename>merb-helpers/spec/fixture/app/models/first_generic_fake_model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,8 @@
 class FakeModel3
   attr_accessor :foo, :bar
+  
+  def new_record?
+    false
+  end
+  
 end</diff>
      <filename>merb-helpers/spec/fixture/app/models/third_generic_fake_model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,7 @@ require File.dirname(__FILE__) + '/spec_helper'
 Merb::Plugins.config[:helpers] = {
   :default_builder =&gt; Merb::Helpers::Form::Builder::FormWithErrors
 }
+class MyClass; end
 
 describe &quot;error_messages_for&quot; do
 
@@ -297,7 +298,7 @@ describe &quot;bound_text_field&quot; do
   it &quot;should errorify a field for a model with errors&quot; do
     model = mock(&quot;model&quot;)
     model.stub!(:new_record?).and_return(true)
-    model.stub!(:class).and_return(&quot;MyClass&quot;)
+    model.stub!(:class).and_return(MyClass)
     model.stub!(:foo).and_return(&quot;FOO&quot;)
     errors = mock(&quot;errors&quot;)
     errors.should_receive(:on).with(:foo).and_return(true)
@@ -345,7 +346,7 @@ describe &quot;bound_radio_button&quot; do
   it &quot;should errorify a field for a model with errors&quot; do
     model = mock(&quot;model&quot;)
     model.stub!(:new_record?).and_return(true)
-    model.stub!(:class).and_return(&quot;MyClass&quot;)
+    model.stub!(:class).and_return(MyClass)
     model.stub!(:foo).and_return(&quot;FOO&quot;)
     errors = mock(&quot;errors&quot;)
     errors.should_receive(:on).with(:foo).and_return(true)
@@ -416,7 +417,7 @@ describe &quot;bound_password_field&quot; do
   it &quot;should errorify a field for a model with errors&quot; do
     model = mock(&quot;model&quot;)
     model.stub!(:new_record?).and_return(true)
-    model.stub!(:class).and_return(&quot;MyClass&quot;)
+    model.stub!(:class).and_return(MyClass)
     model.stub!(:foo).and_return(&quot;FOO&quot;)
     errors = mock(&quot;errors&quot;)
     errors.should_receive(:on).with(:foo).and_return(true)
@@ -579,7 +580,7 @@ describe &quot;bound_check_box&quot; do
   it &quot;should errorify a field for a model with errors&quot; do
     model = mock(&quot;model&quot;)
     model.stub!(:new_record?).and_return(true)
-    model.stub!(:class).and_return(&quot;MyClass&quot;)
+    model.stub!(:class).and_return(MyClass)
     model.stub!(:baz).and_return(&quot;BAZ&quot;)
     model.stub!(:bat).and_return(&quot;BAT&quot;)
     errors = mock(&quot;errors&quot;)
@@ -667,7 +668,7 @@ describe &quot;bound_hidden_field&quot; do
   it &quot;should not errorify a field for a model with errors&quot; do
     model = mock(&quot;model&quot;)
     model.stub!(:new_record?).and_return(true)
-    model.stub!(:class).and_return(&quot;MyClass&quot;)
+    model.stub!(:class).and_return(MyClass)
     model.stub!(:foo).and_return(&quot;FOO&quot;)
     errors = mock(&quot;errors&quot;)
     errors.should_receive(:on).with(:foo).and_return(true)</diff>
      <filename>merb-helpers/spec/merb_helpers_form_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ if defined?(Merb::Plugins)
   require File.dirname(__FILE__) / &quot;merb&quot; / &quot;orms&quot; / &quot;data_mapper&quot; / &quot;connection&quot;
   require File.dirname(__FILE__) / &quot;merb&quot; / &quot;session&quot; / &quot;data_mapper_session&quot;
   Merb::Plugins.add_rakefiles &quot;merb_datamapper&quot; / &quot;merbtasks&quot;
+  ActionORM.use :driver =&gt; :compliant, :for =&gt; DataMapper::Resource
 
   # conditionally assign things, so as not to override previously set options.
   # This is most relevent for :use_repository_block, which is used later in this file.</diff>
      <filename>merb_datamapper/lib/merb_datamapper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>784ac7d71780d1a7cfb9152ba4cb0e18a990ab7a</id>
    </parent>
  </parents>
  <author>
    <name>Matt Aimonetti</name>
    <email>mattaimonetti@gmail.com</email>
  </author>
  <url>http://github.com/wycats/merb/commit/ffff732093da6d300b4652616a8fa150ec758331</url>
  <id>ffff732093da6d300b4652616a8fa150ec758331</id>
  <committed-date>2009-04-27T15:34:41-07:00</committed-date>
  <authored-date>2009-04-27T15:34:41-07:00</authored-date>
  <message>switched merb_datamapper to ActionORM and made sure all the specs were compliant</message>
  <tree>490ced56aa02d133ef5e573318ddfcaff0952e90</tree>
  <committer>
    <name>Matt Aimonetti</name>
    <email>mattaimonetti@gmail.com</email>
  </committer>
</commit>
