lib/anyway/config.rb in anyway_config-1.3.0 vs lib/anyway/config.rb in anyway_config-1.3.1

- old
+ new

@@ -29,16 +29,18 @@ attr_accessor(*new_keys) end def config_name(val = nil) return (@config_name = val.to_s) unless val.nil? + @config_name = underscore_name unless defined?(@config_name) @config_name end def env_prefix(val = nil) return (@env_prefix = val.to_s) unless val.nil? + @env_prefix end # Load config as Hash by any name # @@ -52,10 +54,11 @@ private def underscore_name return unless name + word = name[/^(\w+)/] word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.downcase! word end @@ -73,11 +76,11 @@ def initialize(name: nil, load: true, overrides: {}) @config_name = name || self.class.config_name raise ArgumentError, "Config name is missing" unless @config_name - if @config_name.to_s.include?('_') && @env_prefix.nil? + if @config_name.to_s.include?('_') && self.class.env_prefix.nil? warn "[Deprecated] As your config_name is #{@config_name}, " \ "the prefix `#{@config_name.to_s.delete('_').upcase}` " \ "will be used to parse env variables. " \ "This behavior is about to change in 1.4.0 (no more deleting underscores). " \ "Env prefix can be set explicitly with `env_prefix` method now already " \ @@ -113,9 +116,10 @@ end def load_from_sources(config = {}) # Handle anonymous configs return config unless config_name + load_from_file(config) load_from_env(config) end def load_from_file(config)