Skip to content

Commit 2fcad96

Browse files
committed
Revert "Allow use of DelegateClass in ractor"
This reverts commit 6e0f2b31f0f4a2a942f3c1daad1bb64852fe6815.
1 parent 1e69d68 commit 2fcad96

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

lib/delegate.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,17 @@ def __setobj__(obj)
344344
end
345345
end
346346

347-
def Delegator.delegating_code(mid) # :nodoc:
348-
line = __LINE__+2
349-
src = <<~RUBY
350-
ruby2_keywords def #{mid}(*args, &block)
347+
def Delegator.delegating_block(mid) # :nodoc:
348+
prok = lambda do |*args, &block|
351349
target = self.__getobj__
352-
target.__send__(:'#{mid}', *args, &block)
350+
target.__send__(mid, *args, &block)
351+
end
352+
prok.ruby2_keywords
353+
if defined?(Ractor.shareable_proc)
354+
Ractor.shareable_proc(&prok)
355+
else
356+
prok
353357
end
354-
RUBY
355-
[src, __FILE__, line]
356358
end
357359

358360
#
@@ -431,7 +433,7 @@ def __setobj__(obj) # :nodoc:
431433
class_eval(source.join(";"), __FILE__, __LINE__)
432434

433435
special.each do |method|
434-
module_eval(*Delegator.delegating_code(method))
436+
define_method(method, Delegator.delegating_block(method))
435437
end
436438

437439
protected(*protected_instance_methods)

0 commit comments

Comments
 (0)