module RuGUI::InitializeHooks
Adds before/after hooks for initialize method of a class.
Public Class Methods
included(base)
click to toggle source
# File lib/rugui/initialize_hooks.rb, line 4 def self.included(base) self.update_initialize_method(base) end
update_initialize_method(base)
click to toggle source
# File lib/rugui/initialize_hooks.rb, line 8 def self.update_initialize_method(base) base.class_eval <<-class_eval alias :original_initialize :initialize def initialize(*args) initialize_with_hooks(*args) end class_eval end
Public Instance Methods
initialize_with_hooks(*args)
click to toggle source
Calls the original initialize method with before/after hooks.
# File lib/rugui/initialize_hooks.rb, line 19 def initialize_with_hooks(*args) before_initialize original_initialize(*args) after_initialize end
Protected Instance Methods
after_initialize()
click to toggle source
Called after the initialize method. Subclasses can reimplement this in order to have custom behavior.
# File lib/rugui/initialize_hooks.rb, line 33 def after_initialize end
before_initialize()
click to toggle source
Called before the initialize method. Subclasses can reimplement this in order to have custom behavior.
# File lib/rugui/initialize_hooks.rb, line 28 def before_initialize end