ApplicationController が before_filter で行うのと同じように、それを拡張するクラスがコールバックに登録できるようにする基本クラスを Ruby で作成したいと考えています。
class AController < ApplicationController
before_filter :foo
def foo
end
end
その before_filter の向こう側のようなものを自分で書きたいと思っています。
class AClass < MyBase
register_callback :callback1
def callback1
puts "called!"
end
def test
call_me_maybe 5
end
end
call_me_maybe
メソッドはクラスで定義され、以前MyBase
に登録されたコールバックを呼び出す場合があります。MyBase の実装はどのようなものですか。