74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/reorm/modules/event_modules.rb', line 74
def fire_events(settings={})
events = settings[:events]
if events && !events.empty?
object = (settings[:target] ? settings[:target] : self)
handlers = @@class_events[self.instance_of?(Class) ? self : self.class]
if handlers && !handlers.empty?
events.each do |event|
if handlers.include?(event)
handlers[event].each do |handler|
if !object.respond_to?(handler, true)
raise Error, "Unable to locate a method called '#{handler}' for an instance of the #{object.class.name} class."
end
object.__send__(handler)
end
end
end
end
end
end
|