diff --git a/lib/anyway/config.rb b/lib/anyway/config.rb index d76a346..6c1e155 100644 --- a/lib/anyway/config.rb +++ b/lib/anyway/config.rb @@ -44,7 +44,7 @@ def config_name(val = nil) # my_config = Anyway::Config.for(:my_app) # # will load data from config/my_app.yml, secrets.my_app, ENV["MY_APP_*"] def for(name) - new(name, false).load_from_sources + new(name: name, load: false).load_from_sources end end @@ -56,11 +56,19 @@ def for(name) # # my_config = Anyway::Config.new(:my_app, true, {overrides: {some: :value}}) # - def initialize(config_name = nil, do_load = true, overrides: {}) - @config_name = config_name || self.class.config_name + # rubocop:disable Metrics/LineLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity + def initialize(config_name = nil, do_load = true, name: nil, load: true, overrides: {}) + unless config_name.nil? && do_load.nil? + warn "[Deprecated] Positional arguments for Anyway::Config#initialize will be removed in 1.2.0. Use keyword arguments instead: initialize(name:, load:, overrides:)" + end + name = config_name unless config_name.nil? + load = do_load unless do_load.nil? + + @config_name = name || self.class.config_name raise ArgumentError, "Config name is missing" unless @config_name - load(overrides) if do_load + self.load(overrides) if load end + # rubocop:enable Metrics/LineLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity def reload(overrides = {}) clear