Project

General

Profile

Feature #3511

rb_path_to_class should call custom const_defined? methods

Added by Aaron Patterson about 6 years ago. Updated 20 days ago.

Status:
Feedback
Priority:
Normal
Assignee:
-

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

rb_path_to_class.patch View (1.67 KB) Aaron Patterson, 07/01/2010 07:00 AM

marshal-dynamic.patch View (1.81 KB) George Ogata, 07/05/2016 04:47 AM

History

#1 [ruby-core:43412] Updated by Hiroshi Nakamura over 4 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...

#2 [ruby-core:49693] Updated by Yusuke Endoh over 3 years ago

  • Target version set to next minor

#3 [ruby-core:76071] Updated by George Ogata about 1 month 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?

#4 [ruby-core:76262] Updated by George Ogata 20 days 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.

Also available in: Atom PDF