Class: Facter::ClassDiscoverer
- Inherits:
-
Object
- Object
- Facter::ClassDiscoverer
- Includes:
- Singleton
- Defined in:
- lib/facter/framework/core/fact_loaders/class_discoverer.rb
Instance Method Summary collapse
- #discover_classes(operating_system) ⇒ Object
- #find_nested_classes(mod, discovered_classes) ⇒ Object
-
#initialize ⇒ ClassDiscoverer
constructor
A new instance of ClassDiscoverer.
Constructor Details
#initialize ⇒ ClassDiscoverer
Returns a new instance of ClassDiscoverer.
7 8 9 |
# File 'lib/facter/framework/core/fact_loaders/class_discoverer.rb', line 7 def initialize @log = Log.new(self) end |
Instance Method Details
#discover_classes(operating_system) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/facter/framework/core/fact_loaders/class_discoverer.rb', line 11 def discover_classes() os_module_name = Module.const_get("Facts::#{}") # select only classes find_nested_classes(os_module_name, discovered_classes = []) discovered_classes rescue NameError @log.debug("There is no module named #{}") [] end |
#find_nested_classes(mod, discovered_classes) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/facter/framework/core/fact_loaders/class_discoverer.rb', line 22 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 find_nested_classes(Module.const_get("#{mod.name}::#{constant_name}"), discovered_classes) end end end |