Skip to content

Commit

Permalink
Use self to get the constant
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Oct 1, 2024
1 parent 9038508 commit 62e9211
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/phlex/kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62e9211

Please sign in to comment.