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 a13523e commit ca2e2c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2534,11 +2534,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
9 changes: 5 additions & 4 deletions lib/net/imap/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,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 @@ -246,7 +246,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 @@ -363,9 +363,10 @@ def defaults_hash
version_defaults[:current] = Config[0.4]
version_defaults[:next] = Config[0.5]

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

version_defaults.freeze
end
Expand Down
1 change: 1 addition & 0 deletions test/net/imap/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class ConfigTest < Test::Unit::TestCase
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(:future).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 ca2e2c9

Please sign in to comment.