diff --git a/lib/phlex/kit.rb b/lib/phlex/kit.rb index 7a13da3a..db86509f 100644 --- a/lib/phlex/kit.rb +++ b/lib/phlex/kit.rb @@ -46,23 +46,23 @@ def respond_to_missing?(name, include_private = false) def const_added(name) return if autoload?(name) - me = self constant = const_get(name) if Class === constant && constant < Phlex::SGML constant.include(self) + # Make sure this is not referenced from the below closures constant = nil define_method(name) do |*args, **kwargs, &block| - constant = me.const_get(name) + constant = self.class.const_get(name) render(constant.new(*args, **kwargs), &block) end define_singleton_method(name) do |*args, **kwargs, &block| if (component = Fiber[:__phlex_component__]) component.instance_exec do - constant = me.const_get(name) + constant = self.class.const_get(name) render(constant.new(*args, **kwargs), &block) end else