Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@akicho8

define_method の中から super を呼ぶ方法

module M
  def f
    "ok"
  end
end

class C
  include M

  define_method(:f) do
    super rescue $!              # => #<RuntimeError: implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly.>
    method(:f).super_method.call # => "ok"
    super()                      # => "ok"
  end
end

C.new.f

試行錯誤しつつググったら、明示的に super に引数を渡せばいいようです。
(上記では引数がないことを明示)

参照
Module#define_methodとsuper
http://d.hatena.ne.jp/rubikitch/20080614/1213417931

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
3
Help us understand the problem. What are the problem?