lib/config_x/config_factory.rb in configx-0.5.0 vs lib/config_x/config_factory.rb in configx-0.6.0

- old
+ new

@@ -24,10 +24,14 @@ def default_file_name = "settings" # Default root directory for configuration def default_config_root = "config" + # Default configuration class + # @return [Class<ConfigX::Configurable>] + def default_config_class = UntypedConfig + # Load method to initialize and load the configuration def load(...) = new(...).load end # Initializes a new instance of the ConfigFactory class. @@ -41,27 +45,29 @@ env = self.class.default_env, env_prefix: self.class.default_env_prefix, env_separator: self.class.default_env_separator, dir_name: self.class.default_dir_name, file_name: self.class.default_file_name, - config_root: self.class.default_config_root + config_root: self.class.default_config_root, + config_class: self.class.default_config_class ) @env = env @env_prefix = env_prefix @env_separator = env_separator @dir_name = dir_name @file_name = file_name @config_root = config_root + @config_class = config_class end # Loads the configuration from the sources and additional sources. # @param additional_sources [Array] additional sources to load configuration from. - # @return [Config] the loaded configuration. + # @return [UntypedConfig] the loaded configuration. def load(*additional_sources) (sources + additional_sources) .reduce(Builder.new) { |builder, source| builder.add_source(source) } - .load + .load(config_class:) end private # Returns the sources from which to load the configuration. @@ -85,11 +91,11 @@ # Returns the local setting files. # @return [Array] the local setting files. def local_setting_files [ - (File.join(config_root, "#{file_name}.local.yml") if env != "test"), + File.join(config_root, "#{file_name}.local.yml"), File.join(config_root, dir_name, "#{env}.local.yml") ].compact end # The root directory for configuration. @@ -107,7 +113,10 @@ # The separator for environment variables. attr_reader :env_separator # The file name for settings. attr_reader :file_name + + # The configuration class. + attr_reader :config_class end end