-
Notifications
You must be signed in to change notification settings - Fork 3
Inheriting Callbacks
mosop edited this page Jan 19, 2017
·
6 revisions
Subclasses can inherit callbacks by inherit_callback_group.
class Super
Callback.enable
define_callback_group :super
before_super do
puts "super"
end
end
class Sub < Super
inherit_callback_group :super
before_super do
"super in sub"
end
end
Super.new.run_callbacks_for_super {}
Sub.new.run_callbacks_for_super {}
This prints:
super
super
super in sub