Commits

Michael Granger committed 7feffaf

Simplify Pluggability#derivatives.

  • Participants
  • Parent commits 2ae5714

Comments (0)

Files changed (2)

lib/pluggability.rb

 	### Return the Hash of derivative classes, keyed by various versions of
 	### the class name.
 	def derivatives
-		ancestors.each do |klass|
-			if klass.instance_variables.include?( :@derivatives ) ||
-			   klass.instance_variables.include?( "@derivatives" )
-				return klass.instance_variable_get( :@derivatives )
-			end
-		end
+		return super unless defined?( @derivatives )
+		return @derivatives
 	end
 
 
 	### Inheritance callback -- Register subclasses in the derivatives hash
 	### so that ::create knows about them.
 	def inherited( subclass )
+		Pluggability.logger.debug "%p inherited by %p" % [ self, subclass ]
 		keys = [ subclass ]
 
 		# If it's not an anonymous class, make some keys out of variants of its name

spec/pluggability_spec.rb

 }
 
 require 'rspec'
-require 'logger'
 require 'pluggability'
+require 'spec/lib/helpers'
 
-require 'spec/lib/helpers'
+
+#
+# Testing classes
+#
 
 class Plugin
 	extend Pluggability
 end
 
 
+#
+# Examples
+#
 describe Pluggability do
 
 	before( :each ) do