Skip to content

Commit 17064cd

Browse files
committed
✅ Fix backport compatibility with ruby 2.7
1 parent e4bb734 commit 17064cd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/net/imap/config/attr_type_coercion.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ def self.included(mod)
2626
end
2727
private_class_method :included
2828

29-
def self.safe(...) = Ractor.make_shareable nil.instance_eval(...).freeze
29+
if defined?(Ractor.make_shareable)
30+
def self.safe(...) Ractor.make_shareable nil.instance_eval(...).freeze end
31+
else
32+
def self.safe(...) nil.instance_eval(...).freeze end
33+
end
3034
private_class_method :safe
3135

32-
Types = Hash.new do |h, type| type => Proc | nil; safe{type} end
36+
Types = Hash.new do |h, type|
37+
type.nil? || Proc === type or raise TypeError, "type not nil or Proc"
38+
safe{type}
39+
end
3340
Types[:boolean] = Boolean = safe{-> {!!_1}}
3441
Types[Integer] = safe{->{Integer(_1)}}
3542

0 commit comments

Comments
 (0)