<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,17 +11,14 @@ module Machinist
       named_blueprint = object.class.blueprint(args.shift) if args.first.is_a?(Symbol)
       attributes      = args.pop || {}
 
-      blueprint_chain = [named_blueprint]
-      klass = object.class
-      while klass.respond_to? :blueprint
-        blueprint_chain &lt;&lt; klass.blueprint
-        klass = klass.superclass
-      end
+      raise &quot;No blueprint for class #{object.class}&quot; if blueprint.nil?
 
-      raise &quot;No blueprint for class #{object.class}&quot; if blueprint_chain.compact.empty?
       returning self.new(adapter, object, attributes) do |lathe|
-        blueprint_chain.each do |blueprint|
-          lathe.instance_eval(&amp;blueprint) if blueprint
+        lathe.instance_eval(&amp;named_blueprint) if named_blueprint
+        klass = object.class
+        while klass
+          lathe.instance_eval(&amp;klass.blueprint) if klass.blueprint
+          klass = klass.superclass
         end
       end
     end</diff>
      <filename>lib/machinist.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,18 +2,18 @@ require 'machinist'
 require 'machinist/blueprints'
 
 module Machinist
-
+  
   class ActiveRecordAdapter
-
+    
     def self.has_association?(object, attribute)
       object.class.reflect_on_association(attribute)
     end
-
+    
     def self.class_for_association(object, attribute)
       association = object.class.reflect_on_association(attribute)
       association &amp;&amp; association.klass
     end
-
+    
     # This method takes care of converting any associated objects,
     # in the hash returned by Lathe#assigned_attributes, into their
     # object ids.
@@ -39,14 +39,14 @@ module Machinist
       end
       attributes
     end
-
+    
   end
-
+    
   module ActiveRecordExtensions
     def self.included(base)
       base.extend(ClassMethods)
     end
-
+  
     module ClassMethods
       def make(*args, &amp;block)
         lathe = Lathe.run(Machinist::ActiveRecordAdapter, self.new, *args)
@@ -62,18 +62,14 @@ module Machinist
           yield object if block_given?
         end
       end
-
+        
       def plan(*args)
         lathe = Lathe.run(Machinist::ActiveRecordAdapter, self.new, *args)
         Machinist::ActiveRecordAdapter.assigned_attributes_without_associations(lathe)
       end
-
-      def find_or_make(attrs)
-        find(:first, :conditions =&gt; attrs) || make(attrs)
-      end
     end
   end
-
+  
   module ActiveRecordHasManyExtensions
     def make(*args, &amp;block)
       lathe = Lathe.run(Machinist::ActiveRecordAdapter, self.build, *args)</diff>
      <filename>lib/machinist/active_record.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,11 +15,7 @@ module Machinist
       def named_blueprints
         @blueprints.reject{|name,_| name == :master }.keys
       end
-
-      def has_blueprint?(named = :master)
-        (@blueprints || {}).has_key?(named)
-      end
-
+    
       def clear_blueprints!
         @blueprints = {}
       end</diff>
      <filename>lib/machinist/blueprints.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,46 +27,18 @@ module MachinistActiveRecordSpecs
     end
   
     before(:each) do
-      Person.clear_blueprints!
-      Post.clear_blueprints!
-      Comment.clear_blueprints!
+      [Person, Admin, Post, Comment].each(&amp;:clear_blueprints!)
     end
   
     describe &quot;make method&quot; do
       it &quot;should support single-table inheritance&quot; do
         Person.blueprint { }
+        Admin.blueprint  { }
         admin = Admin.make
         admin.should_not be_new_record
         admin.type.should == &quot;Admin&quot;
       end
 
-      it &quot;should support anonymous and named blueprints for both superclasses and subclasses&quot; do
-        Person.blueprint           { name &quot;John&quot; }
-        Person.blueprint(:special) { name &quot;Paul&quot; }
-        Admin.blueprint            { name &quot;George&quot; }
-        Admin.blueprint(:special)  { name &quot;Ringo&quot; }
-
-        person = Person.make
-        person.should_not be_new_record
-        person.type.should == nil
-        person.name.should == &quot;John&quot;
-
-        person = Person.make(:special)
-        person.should_not be_new_record
-        person.type.should == nil
-        person.name.should == &quot;Paul&quot;
-
-        admin = Admin.make
-        admin.should_not be_new_record
-        admin.type.should == &quot;Admin&quot;
-        admin.name.should == &quot;George&quot;
-
-        admin = Admin.make(:special)
-        admin.should_not be_new_record
-        admin.type.should == &quot;Admin&quot;
-        admin.name.should == &quot;Ringo&quot;
-      end
-
       it &quot;should save the constructed object&quot; do
         Person.blueprint { }
         person = Person.make
@@ -109,17 +81,6 @@ module MachinistActiveRecordSpecs
         Person.make.type.should == &quot;Person&quot;
       end
 
-      describe &quot;subclass blueprint&quot; do
-        it &quot;should augment superclass blueprint, not replace it&quot; do
-          Person.blueprint { name &quot;Bob&quot; }
-          Admin.blueprint  { admin true }
-
-          admin = Admin.make
-          admin.name.should == &quot;Bob&quot;
-          admin.should be_admin
-        end
-      end
-
       describe &quot;on a has_many association&quot; do
         before do 
           Post.blueprint { }</diff>
      <filename>spec/active_record_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,47 +42,19 @@ module MachinistDataMapperSpecs
     end
 
     before(:each) do
-      Person.clear_blueprints!
-      Post.clear_blueprints!
-      Comment.clear_blueprints!
+      [Person, Admin, Post, Comment].each(&amp;:clear_blueprints!)
     end
 
     describe &quot;make method&quot; do
       it &quot;should support inheritance&quot; do
         Person.blueprint {}
+        Admin.blueprint {}
 
         admin = Admin.make
         admin.should_not be_new_record
         admin.type.should_not be_nil
       end
 
-      it &quot;should support anonymous and named blueprints for both superclasses and subclasses&quot; do
-        Person.blueprint           { name &quot;John&quot; }
-        Person.blueprint(:special) { name &quot;Paul&quot; }
-        Admin.blueprint            { name &quot;George&quot; }
-        Admin.blueprint(:special)  { name &quot;Ringo&quot; }
-
-        person = Person.make
-        person.should_not be_new_record
-        person.type.should == MachinistDataMapperSpecs::Person
-        person.name.should == &quot;John&quot;
-
-        person = Person.make(:special)
-        person.should_not be_new_record
-        person.type.should == MachinistDataMapperSpecs::Person
-        person.name.should == &quot;Paul&quot;
-
-        admin = Admin.make
-        admin.should_not be_new_record
-        admin.type.should == MachinistDataMapperSpecs::Admin
-        admin.name.should == &quot;George&quot;
-
-        admin = Admin.make(:special)
-        admin.should_not be_new_record
-        admin.type.should == MachinistDataMapperSpecs::Admin
-        admin.name.should == &quot;Ringo&quot;
-      end
-
       it &quot;should save the constructed object&quot; do
         Person.blueprint { }
         person = Person.make
@@ -108,17 +80,6 @@ module MachinistDataMapperSpecs
       end
     end
 
-    describe &quot;subclass blueprint&quot; do
-      it &quot;should augment superclass blueprint, not replace it&quot; do
-        Person.blueprint { name &quot;Bob&quot; }
-        Admin.blueprint  { admin true }
-
-        admin = Admin.make
-        admin.name.should == &quot;Bob&quot;
-        admin.should be_admin
-      end
-    end
-
     describe &quot;plan method&quot; do
       it &quot;should not save the constructed object&quot; do
         person_count = Person.all.length</diff>
      <filename>spec/data_mapper_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,10 +11,21 @@ module MachinistSpecs
     attr_accessor :title, :body, :published
   end
 
+  class Grandpa
+    attr_accessor :name
+  end
+  
+  class Dad &lt; Grandpa
+    attr_accessor :name
+  end
+
+  class Son &lt; Dad
+    attr_accessor :name
+  end
+
   describe Machinist do
     before(:each) do
-      Person.clear_blueprints!
-      Post.clear_blueprints!
+      [Person, Post, Grandpa, Dad, Son].each(&amp;:clear_blueprints!)
     end
 
     it &quot;should raise for make on a class with no blueprint&quot; do
@@ -127,7 +138,38 @@ module MachinistSpecs
         Person.blueprint(:bar) { }
         Person.named_blueprints.to_set.should == [:admin, :foo, :bar].to_set
       end
-    end  
+    end
+
+    describe &quot;blueprint inheritance&quot; do
+      it &quot;should inherit blueprinted attributes from the parent class&quot; do
+        Dad.blueprint { name &quot;Fred&quot; }
+        Son.blueprint { }
+        Son.make.name.should == &quot;Fred&quot;
+      end
+
+      it &quot;should override blueprinted attributes in the child class&quot; do
+        Dad.blueprint { name &quot;Fred&quot; }
+        Son.blueprint { name &quot;George&quot; }
+        Dad.make.name.should == &quot;Fred&quot;
+        Son.make.name.should == &quot;George&quot;
+      end
+
+      it &quot;should inherit from blueprinted attributes in ancestor class&quot; do
+        Grandpa.blueprint { name &quot;Fred&quot; }
+        Son.blueprint { }
+        Grandpa.make.name.should == &quot;Fred&quot;
+        lambda { Dad.make }.should raise_error(RuntimeError)
+        Son.make.name.should == &quot;Fred&quot;
+      end
+
+      it &quot;should follow inheritance for named blueprints correctly&quot; do
+        Dad.blueprint           { name &quot;John&quot; }
+        Dad.blueprint(:special) { name &quot;Paul&quot; }
+        Son.blueprint           { }
+        Son.blueprint(:special) { }
+        Son.make(:special).name.should == &quot;John&quot;
+      end
+    end
 
     describe &quot;clear_blueprints! method&quot; do
       it &quot;should clear the list of blueprints&quot; do</diff>
      <filename>spec/machinist_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>65ebd711003c24e053c8ac6433cd2736d552f82e</id>
    </parent>
  </parents>
  <author>
    <name>Pete Yandell</name>
    <email>pete@notahat.com</email>
  </author>
  <url>http://github.com/notahat/machinist/commit/9b8b5d2c94499168e23dfe9d2f7bafec765157c7</url>
  <id>9b8b5d2c94499168e23dfe9d2f7bafec765157c7</id>
  <committed-date>2009-08-22T00:02:12-07:00</committed-date>
  <authored-date>2009-08-22T00:02:12-07:00</authored-date>
  <message>Cleaned up inheritance support.

This is my improvements on Rubysolo's patches to make Machinist look at
superclasses when evaluating blueprints. The order of blueprint
evaluation is now: name blueprint, this class's blueprint, parent
class's blueprint, etc.</message>
  <tree>3e3104dc347c6b3fd346502bcfc2b196fe643990</tree>
  <committer>
    <name>Pete Yandell</name>
    <email>pete@notahat.com</email>
  </committer>
</commit>
