module Eventable
Public Instance Methods
fire_event(event, *return_value, &block)
click to toggle source
When the event happens the class where it happens runs this
# File lib/dominate/widget/event.rb, line 21 def fire_event(event, *return_value, &block) check_mutex threads = [] @eventable_mutex.synchronize { return false unless @callbacks && @callbacks[event] && !@callbacks[event].empty? @callbacks[event].each do |listener_id, callbacks| begin listener = ObjectSpace._id2ref(listener_id) callbacks.each do |callback| threads << Thread.new do ThreadUtility.with_connection do listener.send callback, *return_value, &block end end end rescue RangeError => re # Don't bubble up a missing recycled object, I don't care if it's not there, I just won't call it raise re unless re.message.match(/is recycled object/) end end } threads.map(&:join) # Recover lost connections for the pool. A lost connection can occur if a # programmer forgets to checkin a connection at the end of a thread or a # thread dies unexpectedly. ActiveRecord::Base.connection_pool.reap if defined? ActiveRecord true end