diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 87bbfd3..44dbb0c 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -233,7 +233,10 @@ def marshal_dump # :nodoc: # def new_ostruct_member!(name) # :nodoc: unless @table.key?(name) || is_method_protected!(name) - if defined?(::Ractor) + if defined?(::Ractor.shareable_proc) + getter_proc = Ractor.shareable_proc { @table[name] } + setter_proc = Ractor.shareable_proc {|x| @table[name] = x} + elsif defined?(::Ractor) getter_proc = nil.instance_eval{ Proc.new { @table[name] } } setter_proc = nil.instance_eval{ Proc.new {|x| @table[name] = x} } ::Ractor.make_shareable(getter_proc)