63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/observatory/observer.rb', line 63
def overwrite_initialize
class_eval do
unless method_defined?(:initialize_and_setup_observers)
define_method(:initialize_and_setup_observers) do |*args|
initialize_without_observer *args
self.class.observers_to_set_up.each_pair do |name, methods|
methods.each do |m|
@dispatcher.connect(name, method(m))
end
end
end
end
if instance_method(:initialize) != instance_method(:initialize_and_setup_observers)
alias_method :initialize_without_observer, :initialize
alias_method :initialize, :initialize_and_setup_observers
end
end
end
|