<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -200,11 +200,21 @@ module DataMapper
     end
 
     def hooks
-      @hooks ||= Hash.new { |h, k| h[k] = {} }
+      return @hooks if @hooks
+      if self.superclass != Object
+        @hooks = self.superclass.hooks
+      else
+        @hooks = Hash.new { |h, k| h[k] = {} }
+      end
     end
 
     def class_method_hooks
-      @class_method_hooks ||= Hash.new { |h, k| h[k] = {} }
+      return @class_method_hooks if @class_method_hooks
+      if self.superclass != Object
+        @class_method_hooks = self.superclass.class_method_hooks
+      else
+        @class_method_hooks = Hash.new { |h, k| h[k] = {} }
+      end
     end
 
     def quote_method(name)</diff>
      <filename>lib/data_mapper/hook.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,19 @@ describe &quot;DataMapper::Hook&quot; do
     @class.a_class_method
   end
 
+  it 'should run an advice block for class methods when the class is inherited' do
+    @inherited_class = Class.new(@class)
+    
+    @class.before_class_method :a_class_method do
+      hi_dad!
+    end
+
+    @inherited_class.should_receive(:hi_dad!)
+
+    @inherited_class.a_class_method
+  end
+
+
   it 'should run an advice block' do
     @class.before :a_method do
       hi_mom!
@@ -62,6 +75,19 @@ describe &quot;DataMapper::Hook&quot; do
 
     inst.a_method
   end
+  
+  it 'should run an advice block when the class is inherited' do
+    @inherited_class = Class.new(@class)
+    
+    @class.before :a_method do
+      hi_dad!
+    end
+
+    inst = @inherited_class.new
+    inst.should_receive(:hi_dad!)
+
+    inst.a_method
+  end
 
   it 'should run an advice method' do
     @class.class_eval do</diff>
      <filename>spec/unit/hook_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0f57b64a8a8b0d036dd9cee602ceb448ac6a4e88</id>
    </parent>
  </parents>
  <author>
    <name>Alex Coles</name>
    <email>alexbcoles@mac.com</email>
  </author>
  <url>http://github.com/sam/dm-core/commit/613a3676c8c312cf4385cfc142c0741f51deda33</url>
  <id>613a3676c8c312cf4385cfc142c0741f51deda33</id>
  <committed-date>2008-05-13T11:13:17-07:00</committed-date>
  <authored-date>2008-05-13T11:13:17-07:00</authored-date>
  <message>Allow use of hooks defined in a superclass with an inherited class

* Useful in cases of Single Table Inheritance
* Fixes issue # 278

Signed-off-by: Alex Coles &lt;alexbcoles@mac.com&gt;</message>
  <tree>fc853423ec6845ac56a7d069d7a83e802da6ee6e</tree>
  <committer>
    <name>Alex Coles</name>
    <email>alexbcoles@mac.com</email>
  </committer>
</commit>
