Issue #8046 has been updated by charliesome (Charlie Somerville).


=begin
There are two ways to do this - make the extend block execute in the context of the receiver's singleton class, or make it execute in the context of a new module to be mixed in to the receiver's singleton class.

For example:

    def extend(&bk)
      singleton_class.class_eval(&bk)
    end

or

    def extend(&bk)
      singleton_class.send(:include, Module.new(&bk))
    end

Which should it be?
=end
----------------------------------------
Feature #8046: allow Object#extend to take a block
https://bugs.ruby-lang.org/issues/8046#change-37376

Author: phluid61 (Matthew Kerwin)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: next minor


=begin
In #8038 david_macmahon proposed:

How about allowing Object#extend to take a block that would be executed with the context such that methods defined therein would become singleton methods of the object receiving #extend?

For example:
 foo = Object.new
 foo.extend do
   def bar
     # ...
   end
   def baz
     # ...
   end
 end
=end



-- 
http://bugs.ruby-lang.org/