Skip to content

Commit

Permalink
Call Module#const_get once per Module
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcooper committed Dec 8, 2023
1 parent ba58f16 commit 4b00be7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/facter/framework/core/fact_loaders/class_discoverer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ def discover_classes(operating_system)

def find_nested_classes(mod, discovered_classes)
mod.constants.each do |constant_name|
if mod.const_get(constant_name).instance_of? Class
discovered_classes << mod.const_get(constant_name)
elsif mod.const_get(constant_name).instance_of? Module
obj = mod.const_get(constant_name)
if obj.instance_of? Class
discovered_classes << obj
elsif obj.instance_of? Module
find_nested_classes(Module.const_get("#{mod.name}::#{constant_name}"), discovered_classes)
end
end
Expand Down

0 comments on commit 4b00be7

Please sign in to comment.