On Fri, Oct 28, 2011 at 3:40 PM, Intransition <transfire / gmail.com> wrote:
> Can it be done?
>
> E.g.
>
>   >  ®

Funnily enough I stumbled across the very same issue a few days ago.
The reason you can't #extend is

irb(main):001:0> Object.instance_method :extend
=> #<UnboundMethod: Object(Kernel)#extend>

And since

irb(main):002:0> Object < Kernel
=> true
irb(main):003:0> BasicObject < Kernel
=> nil

you cannot bind method extend to an instance of BasicObject:

irb(main):019:0> Object.instance_method(:extend).bind(BasicObject.new)
TypeError: bind argument must be an instance of Object
        from (irb):19:in `bind'
        from (irb):19
        from /opt/bin/irb19:12:in `<main>'


There is just one way I am aware of:

irb(main):010:0> class X < BasicObject
irb(main):011:1> def initialize
irb(main):012:2> class<<self; include ::Enumerable; end
irb(main):013:2> end
irb(main):014:1> end
=> nil
irb(main):015:0> x=X.new
(Object doesn't support #inspect)
=>
irb(main):016:0> Enumerable === x
=> true

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/