Skip to content

Commit 4e14547

Browse files
committed
🐛 Check for Ractor (for JRuby, TruffleRuby)
This is the same code I used in the `v0.4-stable` backport. I didn't use it in the main branch because the minimum ruby version is 3.1. But that breaks when JRuby and TruffleRuby try to `require "net/imap"`. Fixes #452.
1 parent 364869b commit 4e14547

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/net/imap/config/attr_type_coercion.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ def self.included(mod)
2828
end
2929
private_class_method :included
3030

31-
def self.safe(...) = Ractor.make_shareable nil.instance_eval(...).freeze
31+
if defined?(Ractor.make_shareable)
32+
def self.safe(...) Ractor.make_shareable nil.instance_eval(...).freeze end
33+
else
34+
def self.safe(...) nil.instance_eval(...).freeze end
35+
end
3236
private_class_method :safe
3337

3438
Types = Hash.new do |h, type| type => Proc | nil; safe{type} end

0 commit comments

Comments
 (0)