Permalink
Browse files

Implemented basic inheritance.

  • Loading branch information...
1 parent 569be26 commit 0e473322643caaf6f05af63f1445e3d31fac7dd7 dfue committed Feb 16, 2009
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/shadows.rb
View
@@ -1,9 +1,9 @@
module Shadows
- def self.shadow_class(base)
+ def self.shadow_class(base, fallback = nil)
"#{ base.name }Shadow".constantize
rescue NameError => e
- Class.new Shadows::Base do
+ fallback or Class.new Shadows::Base do
helper = "#{ base.name.pluralize }Helper".constantize rescue nil
include helper if helper
end
@@ -43,6 +43,10 @@ def self.extended(base)
base.instance_variable_set :@shadow, Shadows.shadow_class(base)
end
attr_reader :shadow
+ def inherited(base)
+ super
+ base.instance_variable_set :@shadow, Shadows.shadow_class(base, @shadow)
+ end
end
module InstanceMethods

0 comments on commit 0e47332

Please sign in to comment.