Skip to content

Commit

Permalink
🔇 Fix ruby 2.7 warning: ivar not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Jun 22, 2024
1 parent 958e872 commit 1920a38
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/net/imap/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Config
def self.default; @default end

# The global config object. Also available from Net::IMAP.config.
def self.global; @global end
def self.global; @global if defined?(@global) end

# A hash of hard-coded configurations, indexed by version number.
def self.version_defaults; @version_defaults end
Expand All @@ -149,12 +149,11 @@ def self.version_defaults; @version_defaults end
#
# Given a config, returns that same config.
def self.[](config)
if config.is_a?(Config) || config.nil? && global.nil?
config
elsif config.respond_to?(:to_hash)
new(global, **config).freeze
if config.is_a?(Config) then config
elsif config.nil? && global.nil? then nil
elsif config.respond_to?(:to_hash) then new(global, **config).freeze
else
version_defaults.fetch(config) {
version_defaults.fetch(config) do
case config
when Numeric
raise RangeError, "unknown config version: %p" % [config]
Expand All @@ -165,7 +164,7 @@ def self.[](config)
config.class, Config
]
end
}
end
end
end

Expand Down

0 comments on commit 1920a38

Please sign in to comment.