lib/dev_suite/utils/construct/config/manager.rb in dev_suite-0.2.5 vs lib/dev_suite/utils/construct/config/manager.rb in dev_suite-0.2.6

- old
+ new

@@ -3,29 +3,37 @@ module DevSuite module Utils module Construct module Config module Manager - # Provides access to a single instance of the configuration class - # It dynamically uses the Configuration class in the including module's namespace - def configuration - @configuration ||= self::Configuration.new + class << self + def included(base) + base.extend(ClassMethods) + end end - # Allows block-based configuration - # Example usage: - # ConfigClass.configure do |config| - # config.attr_name = value - # end - def configure - yield(configuration) - rescue StandardError => e - ErrorHandler.handle_error(e) - end + module ClassMethods + # Provides access to a single instance of the configuration class + # It dynamically uses the Configuration class in the including module's namespace + def configuration + @configuration ||= self::Configuration.new + end - # Resets the configuration by reinitializing it with default values - def reset! - @configuration = self::Configuration.new # Reinitialize the configuration instance + # Allows block-based configuration + # Example usage: + # ConfigClass.configure do |config| + # config.attr_name = value + # end + def configure + yield(configuration) + rescue StandardError => e + ErrorHandler.handle_error(e) + end + + # Resets the configuration by reinitializing it with default values + def reset! + @configuration = self::Configuration.new # Reinitialize the configuration instance + end end end end end end