Skip to content

Commit

Permalink
🔧 Set responses_without_block to frozen_dup in 0.6
Browse files Browse the repository at this point in the history
This seems like a better API than _always_ crashing.  Now that we have a
config option for it, it should become the default in v0.6.
  • Loading branch information
nevans committed Oct 13, 2024
1 parent 5ac99b2 commit 566e668
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2528,11 +2528,11 @@ def idle_done
# Prints a warning and returns the mutable responses hash.
# <em>This is not thread-safe.</em>
#
# [+:frozen_dup+</em>]
# [+:frozen_dup+ <em>(planned default for +v0.6+)</em>]
# Returns a frozen copy of the unhandled responses hash, with frozen
# array values.
#
# [+:raise+ <em>(planned future default)</em>]
# [+:raise+]
# Raise an +ArgumentError+ with the deprecation warning.
#
# For example:
Expand Down
13 changes: 6 additions & 7 deletions lib/net/imap/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def self.[](config)
# Prints a warning and returns the mutable responses hash.
# <em>This is not thread-safe.</em>
#
# [+:frozen_dup+</em>]
# [+:frozen_dup+ <em>(planned default for +v0.6+)</em>]
# Returns a frozen copy of the unhandled responses hash, with frozen
# array values.
#
Expand All @@ -269,7 +269,7 @@ def self.[](config)
#
# <em>(+:frozen_dup+ config option was added in +v0.4.17+)</em>
#
# [+:raise+ <em>(planned future default)</em>]
# [+:raise+]
# Raise an ArgumentError with the deprecation warning.
#
# Note: #responses_without_args is an alias for #responses_without_block.
Expand Down Expand Up @@ -388,12 +388,11 @@ def defaults_hash

version_defaults[0.5] = Config[:current]

version_defaults[0.6] = Config[0.5]
version_defaults[:next] = Config[0.6]

version_defaults[:future] = Config[0.6].dup.update(
responses_without_block: :raise,
version_defaults[0.6] = Config[0.5].dup.update(
responses_without_block: :frozen_dup,
).freeze
version_defaults[:next] = Config[0.6]
version_defaults[:future] = Config[:next]

version_defaults.freeze
end
Expand Down
2 changes: 1 addition & 1 deletion test/net/imap/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class ConfigTest < Test::Unit::TestCase
assert_same Config.default, Config.new(Config.default).parent
assert_same Config.global, Config.new(Config.global).parent
assert_same Config[0.4], Config.new(0.4).parent
assert_same Config[0.5], Config.new(:next).parent
assert_same Config[0.6], Config.new(:next).parent
assert_equal true, Config.new({debug: true}, debug: false).parent.debug?
assert_equal true, Config.new({debug: true}, debug: false).parent.frozen?
end
Expand Down

0 comments on commit 566e668

Please sign in to comment.