Project

General

Profile

Actions

Bug #9526

closed

Method#owner returns wrong owner if using prepend.

Added by yui-knk (Kaneko Yuichiro) about 10 years ago. Updated about 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby-2.0.0-p353 [ x86_64 ] & ruby-2.1.0 [ x86_64 ]
[ruby-dev:47975]

Description

rdoc indicates that Method#owner will return a class or module that defines a method.
http://www.ruby-doc.org/core-2.0/Method.html#method-i-owner


module MyMod
def x(y)
super(y*y)
end
end

class Blah
def x(y)
y + 1
end
prepend MyMod
end

Blah.new.method(:x).owner
# => MyMod


In this case, a class or module that defines a method is Blah.
So I think Blah.new.method(:x).owner should return Blah.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0