Project

General

Profile

Actions

Feature #5505

closed

BasicObject#__extend__

Feature #5505: BasicObject#__extend__

Added by trans (Thomas Sawyer) almost 14 years ago. Updated almost 14 years ago.

Status:
Rejected
Assignee:
-
Target version:
[ruby-core:40492]

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.

Updated by nobu (Nobuyoshi Nakada) almost 14 years ago Actions #1 [ruby-core:40493]

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

Updated by matz (Yukihiro Matsumoto) almost 14 years ago Actions #2 [ruby-core:40494]

  • Status changed from Open to Rejected

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

should work.

Updated by aprescott (Adam Prescott) almost 14 years ago Actions #3 [ruby-core:40495]

On Fri, Oct 28, 2011 at 3:17 PM, Yukihiro Matsumoto wrote:

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

should work.

It doesn't, but this does:

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

Updated by trans (Thomas Sawyer) almost 14 years ago Actions #4

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 (Yukihiro Matsumoto) 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.

Actions

Also available in: PDF Atom