Skip to content

Commit

Permalink
Fix an issue with include multiple Phlex Kits (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper authored Sep 29, 2024
1 parent 739cb8d commit c534a98
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/phlex/kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,44 @@
module Phlex::Kit
module LazyLoader
def method_missing(name, ...)
if name[0] == name[0].upcase && __phlex_kit_constants__.include?(name) && __get_phlex_kit_constant__(name) && methods.include?(name)
mod = self.class

if name[0] == name[0].upcase && mod.constants.include?(name) && mod.const_get(name) && methods.include?(name)
public_send(name, ...)
else
super
end
end

def respond_to_missing?(name, include_private = false)
if name[0] == name[0].upcase && __phlex_kit_constants__.include?(name) && __get_phlex_kit_constant__(name) && methods.include?(name)
mod = self.class

if name[0] == name[0].upcase && mod.constants.include?(name) && mod.const_get(name) && methods.include?(name)
true
else
super
end
end
end

include LazyLoader

def self.extended(mod)
mod.include(LazyLoader)
mod.define_method(:__phlex_kit_constants__) { mod.__phlex_kit_constants__ }
mod.define_method(:__get_phlex_kit_constant__) { |name| mod.__get_phlex_kit_constant__(name) }
end

def __phlex_kit_constants__
constants
def method_missing(name, ...)
if name[0] == name[0].upcase && constants.include?(name) && const_get(name) && methods.include?(name)
public_send(name, ...)
else
super
end
end

def __get_phlex_kit_constant__(name)
const_get(name)
def respond_to_missing?(name, include_private = false)
if name[0] == name[0].upcase && constants.include?(name) && const_get(name) && methods.include?(name)
true
else
super
end
end

def const_added(name)
Expand Down

0 comments on commit c534a98

Please sign in to comment.