We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4bb734 commit 17064cdCopy full SHA for 17064cd
lib/net/imap/config/attr_type_coercion.rb
@@ -26,10 +26,17 @@ def self.included(mod)
26
end
27
private_class_method :included
28
29
- def self.safe(...) = Ractor.make_shareable nil.instance_eval(...).freeze
+ 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
34
private_class_method :safe
35
- 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
40
Types[:boolean] = Boolean = safe{-> {!!_1}}
41
Types[Integer] = safe{->{Integer(_1)}}
42
0 commit comments