<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,18 +4,18 @@ module CouchRest
   class Document &lt; Response
     include CouchRest::Mixins::Attachments
 
+    # def self.inherited(subklass)
+    #   subklass.send(:class_inheritable_accessor, :database)
+    # end
+    
+    class_inheritable_accessor :database
     attr_accessor :database
-    @@database = nil
     
     # override the CouchRest::Model-wide default_database
     # This is not a thread safe operation, do not change the model
     # database at runtime.
     def self.use_database(db)
-      @@database = db
-    end
-    
-    def self.database
-      @@database
+      self.database = db
     end
     
     def id</diff>
      <filename>lib/couchrest/core/document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -118,7 +118,7 @@ module CouchRest
     # Overridden to set the unique ID.
     # Returns a boolean value
     def save_without_callbacks(bulk = false)
-      raise ArgumentError, &quot;a document requires a database to be saved to&quot; unless database
+      raise ArgumentError, &quot;a document requires a database to be saved to (The document or the #{self.class} default database were not set)&quot; unless database
       set_unique_id if new_document? &amp;&amp; self.respond_to?(:set_unique_id)
       result = database.save_doc(self, bulk)
       result[&quot;ok&quot;] == true</diff>
      <filename>lib/couchrest/more/extended_document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module CouchRest
   class Property
     # flag letting us know if we already checked the autovalidation settings
     attr_accessor :autovalidation_check
-    @@autovalidation_check = false
+    @autovalidation_check = false
   end
 
   module Validation
@@ -71,7 +71,7 @@ module CouchRest
       #       validator to be created for the property.  integer_only
       #       is set to true
       #
-      #   BigDecimal or Float type
+      #   Float type
       #       Using a Integer type causes a validates_is_number
       #       validator to be created for the property.  integer_only
       #       is set to false, and precision/scale match the property
@@ -91,13 +91,14 @@ module CouchRest
       #       It is just shortcut if only one validation option is set
       #
       def auto_generate_validations(property)
-        return unless (property.autovalidation_check &amp;&amp; self.auto_validation &amp;&amp; (property.options &amp;&amp; property.options.has_key?(:auto_validation) &amp;&amp; property.options[:auto_validation]))
+        return unless ((property.autovalidation_check != true) &amp;&amp; self.auto_validation)
+        return if (property.options &amp;&amp; (property.options.has_key?(:auto_validation) &amp;&amp; !property.options[:auto_validation]) || property.read_only)
         # value is set by the storage system
         opts = {}
         opts[:context] = property.options[:validates] if property.options.has_key?(:validates)
 
         # presence
-        unless opts[:allow_nil]
+        if opts[:allow_nil] == false
           # validates_present property.name, opts
           validates_present property.name, options_with_message(opts, property, :presence)
         end</diff>
      <filename>lib/couchrest/validation/auto_validate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,6 @@ class DummyModel &lt; CouchRest::ExtendedDocument
   property :casted_attribute, :cast_as =&gt; 'WithCastedModelMixin'
 end
 
-
 describe CouchRest::CastedModel do
   
   describe &quot;A non hash class including CastedModel&quot; do
@@ -59,7 +58,7 @@ describe CouchRest::CastedModel do
   describe &quot;saved document with casted models&quot; do
     before(:each) do
       @obj = DummyModel.new(:casted_attribute =&gt; {:name =&gt; 'whatever'})
-      @obj.save
+      @obj.save.should be_true
     end
     
     it &quot;should be able to load with the casted models&quot; do</diff>
      <filename>spec/couchrest/more/casted_model_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -37,10 +37,7 @@ describe &quot;ExtendedDocument properties&quot; do
   it &quot;should be auto timestamped&quot; do
     @card.created_at.should be_nil
     @card.updated_at.should be_nil
-    # :emo: hack for autospec
-    Card.use_database(TEST_SERVER.default_database) if @card.database.nil?
-    @card.save #.should be_true
-    p @card.errors
+    @card.save.should be_true
     @card.created_at.should_not be_nil
     @card.updated_at.should_not be_nil
   end
@@ -73,9 +70,6 @@ describe &quot;ExtendedDocument properties&quot; do
     it &quot;should let you set an error message&quot; do
       @invoice.location = nil
       @invoice.valid?
-      # require 'ruby-debug'
-      # debugger
-      # p @invoice.class.validators.map{|v| v.message}.inspect
       @invoice.errors.on(:location).should == [&quot;Hey stupid!, you forgot the location&quot;]
     end
     
@@ -108,7 +102,7 @@ describe &quot;ExtendedDocument properties&quot; do
         @service.name = nil
         @service.should_not be_valid
         @service.errors.should_not be_nil
-        @service.errors.on(:name).first.should == &quot;Name must not be blank&quot;
+        @service.errors.on(:name).first.should == &quot;Name must be between 4 and 19 characters long&quot;
       end
     
       it &quot;should autovalidate the correct length&quot; do</diff>
      <filename>spec/couchrest/more/property_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class Service &lt; CouchRest::ExtendedDocument  
   # Include the validation module to get access to the validation methods
   include CouchRest::Validation
-  
+  auto_validate!
   # Set the default database to use
   use_database TEST_SERVER.default_database
   
@@ -9,6 +9,4 @@ class Service &lt; CouchRest::ExtendedDocument
   property :name, :length =&gt; 4...20
   property :price, :type =&gt; Integer
   
-  auto_validate!
-  
 end
\ No newline at end of file</diff>
      <filename>spec/fixtures/more/service.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e448112ff64cf659b19822e50214b14893805aa6</id>
    </parent>
  </parents>
  <author>
    <name>Matt Aimonetti</name>
    <email>mattaimonetti@gmail.com</email>
  </author>
  <url>http://github.com/mattetti/couchrest/commit/c0abafd1e0c5e928fc04d6c840a21823cb82fb4a</url>
  <id>c0abafd1e0c5e928fc04d6c840a21823cb82fb4a</id>
  <committed-date>2009-02-10T16:10:35-08:00</committed-date>
  <authored-date>2009-02-10T16:10:35-08:00</authored-date>
  <message>fixed a major bug with inheritance and the class database setup. (plus some validation bugs)</message>
  <tree>ae53db784738b043d4f513f7ba79712c3b87c3d3</tree>
  <committer>
    <name>Matt Aimonetti</name>
    <email>mattaimonetti@gmail.com</email>
  </committer>
</commit>
