Skip to content

Commit 9c37c6c

Browse files
committed
🐛 Fix loading of Net::IMAP::Config for JRuby
1 parent b97b414 commit 9c37c6c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/net/imap/config/attr_type_coercion.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def self.included(mod)
3030

3131
if defined?(Ractor.shareable_proc)
3232
def self.safe(&b)
33-
case obj = b.call
33+
case obj = nil.instance_eval(&b).freeze
3434
when Proc
3535
Ractor.shareable_proc(&obj)
3636
else
@@ -59,12 +59,11 @@ def self.attr_accessor(attr, type: nil)
5959

6060
NilOrInteger = safe{->val { Integer val unless val.nil? }}
6161

62-
Enum = ->(*enum) {
63-
sh_enum = Ractor.make_shareable(enum)
64-
safe_enum = safe{sh_enum}
65-
expected = -"one of #{safe_enum.map(&:inspect).join(", ")}"
62+
Enum = ->(*unsafe_enum) {
63+
enum = safe{unsafe_enum}
64+
expected = -"one of #{enum.map(&:inspect).join(", ")}"
6665
safe{->val {
67-
return val if safe_enum.include?(val)
66+
return val if enum.include?(val)
6867
raise ArgumentError, "expected %s, got %p" % [expected, val]
6968
}}
7069
}

0 commit comments

Comments
 (0)