Feature #5505

BasicObject#__extend__

Added by Thomas Sawyer over 2 years ago. Updated over 2 years ago.

[ruby-core:40492]
Status:Rejected
Priority:Normal
Assignee:-
Category:-
Target version:2.0.0

Description

Unless there is already some way to do it that I've overlooked, the it would be nice if there were still some way to extend an instance of BasicObject.

Probably the easiest way is defining #extend.

History

#1 Updated by Nobuyoshi Nakada over 2 years ago

Try Kernel.send(:extend_object, BasicObject.new)

#2 Updated by Yukihiro Matsumoto over 2 years ago

  • Status changed from Open to Rejected

o = BasicObject.new
class <<o
include Enumerable
end

should work.

#3 Updated by Adam Prescott over 2 years ago

On Fri, Oct 28, 2011 at 3:17 PM, Yukihiro Matsumoto matz@ruby-lang.orgwrote:

o = BasicObject.new
class <<o
include Enumerable
end

should work.

It doesn't, but this does:

o = BasicObject.new
class <<o
include ::Enumerable
end

#4 Updated by Thomas Sawyer over 2 years ago

Ah, right I forgot about this... what do you call it? The "callback"?

It needs to be:

Enumerable.send(:extend_object, BasicObject.new)

but it worked.

@matz thanks that will work too --although with a little more meta-programming if the module was in a variable.

Thanks. Sorry for the noise. Should have put the question on ruby-talk instead... but there so little communication actually going on there these days.

Also available in: Atom PDF