Help us understand the problem. What is going on with this article?

define_method の中から super を呼ぶ方法

More than 5 years have passed since last update.
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

akicho8
Ruby脳にムチ打って泣きながらVue.jsをやっています
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした