Project

General

Profile

Feature #3511

rb_path_to_class should call custom const_defined? methods

Added by tenderlovemaking (Aaron Patterson) almost 9 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-

Description

=begin
It would be nice if rb_path_to_class called custom const_defined? methods. This would give marshaled objects a chance to locate and define classes when they are being unmarshalled.

I've attached a patch with a test that demonstrates the desired functionality and a (probably naive) implementation.
=end


Files

rb_path_to_class.patch (1.67 KB) rb_path_to_class.patch tenderlovemaking (Aaron Patterson), 07/01/2010 07:00 AM
marshal-dynamic.patch (1.81 KB) marshal-dynamic.patch oggy (George Ogata), 07/05/2016 04:47 AM

History

Updated by nahi (Hiroshi Nakamura) over 7 years ago

  • Description updated (diff)
  • Status changed from Open to Feedback

Aaron, is this hook extension still needed for your usecase? (assuming Rails?)

Not bad but it would affect performance...

Updated by mame (Yusuke Endoh) over 6 years ago

  • Target version set to 2.6

Updated by oggy (George Ogata) about 3 years ago

Hiroshi Nakamura wrote:

Aaron, is this hook extension still needed for your usecase? (assuming Rails?)

Not bad but it would affect performance...

Would this idea still be considered? I find this issue comes up fairly frequently in Rails apps when an object is serialized and deserialized in a separate process.

I think the performance problem could be addressed by keeping the rb_const_defined call, and then only if that fails try the rb_funcall. WDYT?

Updated by oggy (George Ogata) almost 3 years ago

I've attached an updated patch for current ruby trunk, which I think is a little more consistent with non-lazily-defined constant lookup. Also simplified the test case a little.

Updated by matz (Yukihiro Matsumoto) almost 3 years ago

  • Status changed from Feedback to Closed

This is kind of autoload that sometimes cause problems.
I think it can cause issues than solving problem.
If you have a concrete use-case of this feature, please reopen.

Matz.

Updated by oggy (George Ogata) almost 3 years ago

Thanks for considering!

I've opened a new ticket and described my concrete use case, as I don't see a way to reopen this one.

https://bugs.ruby-lang.org/issues/12731

Also available in: Atom PDF