Ruby 3.0.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Methodクラス > super_method

instance method Method#super_method

super_method -> Method | nil[permalink][rdoc]

self 内で super を実行した際に実行されるメソッドを Method オブジェクトにして返します。

[SEE_ALSO] UnboundMethod#super_method



class Super
  def foo
    "superclass method"
  end
end

class Sub < Super
  def foo
    "subclass method"
  end
end

m = Sub.new.method(:foo) # => #<Method: Sub#foo>
m.call # => "subclass method"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"