# * BOOH * # # A.k.a `Best web-album Of the world, Or your money back, Humerus'. # # The acronyn sucks, however this is a tribute to Dragon Ball by # Akira Toriyama, where the last enemy beaten by heroes of Dragon # Ball is named "Boo". But there was already a free software project # called Boo, so this one will be it "Booh". Or whatever. # # # Copyright (c) 2004 Guillaume Cottenceau # # This software may be freely redistributed under the terms of the GNU # public license version 2. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # # Any method call to the wrapped object will be synchronized on a unique # monitor. Recursive calls are possible. # require 'monitor' class ObjectWrapper def initialize(wrapped_object) @wrapped_object = wrapped_object end def method_missing(id, *args, &block) wrap(id, *args, &block) end def wrap(id, *args, &block) if block.nil? return @wrapped_object.__send__(id, *args) else return @wrapped_object.__send__(id, *args) { |*args2| block.call(*args2) } end end end class Synchronizator < ObjectWrapper def initialize(wrapped_object) super @wrapped_object.extend(MonitorMixin) end def wrap(id, *args, &block) @wrapped_object.synchronize { super(id, *args, &block) } end end