Module: Synchronizer::ClassMethods

Defined in:
lib/RubyExt/Synchronizer.rb

Instance Method Summary collapse

Instance Method Details

#synchronize(*methods) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/RubyExt/Synchronizer.rb', line 5

def synchronize *methods
	methods.each do |name|							
		als = (name.to_s =~ /^[_a-zA-Z0-9]+$/) ? name : RubyExt::Cache.alias_counter.to_sym
		
		alias_method :"sync_#{als}", name
		script = "\
def #{name} *p, &b
	synchronize{sync_#{als} *p, &b}
end"
		class_eval script, __FILE__, __LINE__
	end
end

#synchronize_allObject



18
19
20
21
# File 'lib/RubyExt/Synchronizer.rb', line 18

def synchronize_all
	methods = self.instance_methods(false).collect{|m| m.to_sym}
	synchronize *methods
end