summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Gruber <luke.gruber@shopify.com>2025-12-12 13:54:42 -0500
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-12-18 16:46:29 +0900
commit01e9f95cc3d796bc7bf4f809016712c52f330d74 (patch)
treecd19f3f30be34d97c521437bb424eea6df2b3045 /lib
parent85ff21c9e5986c52814b7e5ed3402e2a964c542e (diff)
[ruby/delegate] Allow use of DelegateClass in ractors
Tempfile uses DelegateClass and Tempfile should be able to be used by different ractors. https://github.com/ruby/delegate/commit/cad194260b
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 838de675f1..b5224ea15f 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -345,10 +345,16 @@ class SimpleDelegator < Delegator
end
def Delegator.delegating_block(mid) # :nodoc:
- lambda do |*args, &block|
+ prok = lambda do |*args, &block|
target = self.__getobj__
target.__send__(mid, *args, &block)
- end.ruby2_keywords
+ end
+ prok.ruby2_keywords
+ if defined?(Ractor.shareable_proc)
+ Ractor.shareable_proc(&prok)
+ else
+ prok
+ end
end
#