diff --git a/lib/phlex/kit.rb b/lib/phlex/kit.rb index 5efd53d4..941d9114 100644 --- a/lib/phlex/kit.rb +++ b/lib/phlex/kit.rb @@ -24,7 +24,16 @@ def respond_to_missing?(name, include_private = false) end def self.extended(mod) - mod.include(LazyLoader) + case mod + when Class + raise Phlex::ArgumentError.new(<<~MESSAGE) + `Phlex::Kit` was extended into #{mod.name}. + + You should only extend modules with `Phlex::Kit` as it is not compatible with classes. + MESSAGE + else + mod.include(LazyLoader) + end end def method_missing(name, ...) @@ -52,7 +61,7 @@ def const_added(name) case constant when Class if constant < Phlex::SGML - constant.include(self) + constant.include(me) constant = nil @@ -74,7 +83,7 @@ def const_added(name) end end when Module - constant.extend(Phlex::Kit) unless Class === constant + constant.extend(Phlex::Kit) end super