--mimepart_4d29b0e4b3354_1f2bb2a32d4256e
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

Feature #4254: Allow method transplanting
http://redmine.ruby-lang.org/issues/show/4254

Author: Jonas Pfenniger
Status: Open, Priority: Normal
Category: core, Target version: 1.9.3

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.


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

--mimepart_4d29b0e4b3354_1f2bb2a32d4256e
Content-Type: text/plain; name=0001-method-transplanting-Allow-to-set-an-UnboundMethod-t.patch
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=0001-method-transplanting-Allow-to-set-an-UnboundMethod-t.patch

RnJvbSAwMzM2ZWMzMzRmN2ViNjZkMmNmMDViZDdhMjlkNzQ4NzgwZDYwNDRl
IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBKb25hcyBQZmVubmln
ZXIgPGpvbmFzQHBmZW5uaWdlci5uYW1lPgpEYXRlOiBTdW4sIDkgSmFuIDIw
MTEgMDA6MTM6NTcgKzAwMDAKU3ViamVjdDogW1BBVENIXSBtZXRob2QgdHJh
bnNwbGFudGluZzogQWxsb3cgdG8gc2V0IGFuIFVuYm91bmRNZXRob2QgdG8g
YW55IG1vZHVsZS4KCkl0J3MgdGltZSB0byBncm93IHVwLCByZW1vdmUgdGhl
IHNlY3VyaXR5IG5ldHMuCi0tLQogcHJvYy5jIHwgICAxMSAtLS0tLS0tLS0t
LQogMSBmaWxlcyBjaGFuZ2VkLCAwIGluc2VydGlvbnMoKyksIDExIGRlbGV0
aW9ucygtKQoKZGlmZiAtLWdpdCBhL3Byb2MuYyBiL3Byb2MuYwppbmRleCA3
ZGYyZWM4Li42NTJiM2UxIDEwMDY0NAotLS0gYS9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