From: "phluid61 (Matthew Kerwin)" Date: 2013-03-08T13:05:10+09:00 Subject: [ruby-core:53214] [ruby-trunk - Feature #8046] allow Object#extend to take a block Issue #8046 has been updated by phluid61 (Matthew Kerwin). charliesome (Charlie Somerville) wrote: > 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. > ... > Which should it be? I'd think more like the former, as that doesn't inject a new anonymous Module into the singleton_class's #ancestors. Does class_eval do anything dramatically different from module_eval (i.e. is the block handled differently in either case)? ---------------------------------------- Feature #8046: allow Object#extend to take a block https://bugs.ruby-lang.org/issues/8046#change-37377 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/