Making some fixes regarding calling custom modules

from singleton methods
This commit is contained in:
VetheonGames 2023-10-27 17:09:12 -06:00
parent b4ee7f77e7
commit 38496a133f
3 changed files with 16 additions and 11 deletions

View File

@ -60,7 +60,7 @@ ConfigMan.setup(default_modules)
## Wiki
For more detailed information and advanced usage, please refer to our [Wiki](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/ConfigMan/wiki)).
For more detailed information and advanced usage, please refer to our [Wiki](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/ConfigMan/wiki/ConfigMan-Wiki-Home).
## Contributing

View File

@ -43,7 +43,6 @@ module ConfigMan # rubocop:disable Metrics/ModuleLength, Style/Documentation
@custom_modules ||= []
@custom_modules << mod_class
puts "Custom modules: #{@custom_modules.inspect}" # Debug line
end
def self.used_modules
@ -135,17 +134,23 @@ module ConfigMan # rubocop:disable Metrics/ModuleLength, Style/Documentation
end
end
# Load configurations from the .config file
def self.load
# Load configurations from the .config file
def self.load
config_file_path = File.join(Dir.pwd, '.config')
parsed_config = send_to_parser(config_file_path)
# Merge custom modules' configurations into parsed_config
@custom_modules.each do |mod_class|
custom_config = mod_class.populate_defaults
parsed_config.merge!(custom_config)
end
parsed_config.each do |module_name, config|
define_singleton_method(module_name) do
config
end
end
end
end
# Delegate to the appropriate parser to parse the file
def self.send_to_parser(file_path)

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module ConfigMan
VERSION = '1.0.0'
VERSION = '1.0.1'
end