Issue #4254 has been updated by trans (Thomas Sawyer).


That makes sense. But I am not sure it matters a great deal. Modules too can have interdependent methods and reference instance variables. I get the concept, but ultimately I'd just prefer to have full flexibility and be done with it, rather than having to fuss with the limitations. This is a meta-programming feature and like all such techniques it requires care by the developer.

However, I am also coming at this with very particular use case in mind. I would make little girl squeally noises to be able to define a method that could include a module that would also include it's class methods. Being able to transplant class methods would make that possible (albeit not the most elegant approach). If there were another means of doing that, then I wouldn't care as much about transplanting class methods.

----------------------------------------
Feature #4254: Allow method transplanting
https://bugs.ruby-lang.org/issues/4254#change-27416

Author: zimbatm (Jonas Pfenniger)
Status: Closed
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 2.0.0


=begin
Is there a technical reason to not allow re-binding a method from one module to any other module ?
 
  module M
    def foo; "foo"; end
  end

  module N; end
  N.send(:define_method, :foo, M.instance_method(:foo)) #=> should not raise
 
It's like monkey-patching. Powerful, dangerous, but also really useful. It could allow different variations of method_wrap or alias_method_chain that are not possible right now.
=end



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