diff options
author | Nick <nick@nicksieger.com> | 2008-04-19 10:18:02 -0500 |
---|---|---|
committer | Nick Sieger <nick@nicksieger.com> | 2008-08-29 14:12:09 -0500 |
commit | 9dc4f6611043d032e576d93430cd29efc8864bc4 (patch) | |
tree | 69473e5bbc8a4059a94c55ddac4eacb45180c1ca /activesupport/lib/active_support/core_ext/module | |
parent | 3eb68248e0c0495c4533792260c9262fcd2840af (diff) | |
download | rails-9dc4f6611043d032e576d93430cd29efc8864bc4.tar.gz rails-9dc4f6611043d032e576d93430cd29efc8864bc4.tar.bz2 rails-9dc4f6611043d032e576d93430cd29efc8864bc4.zip |
Add method punctuation handling to #synchronize
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/synchronization.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/synchronization.rb b/activesupport/lib/active_support/core_ext/module/synchronization.rb index bf7740f851..c55a3f07ee 100644 --- a/activesupport/lib/active_support/core_ext/module/synchronization.rb +++ b/activesupport/lib/active_support/core_ext/module/synchronization.rb @@ -19,13 +19,15 @@ class Module end methods.each do |method| - if instance_methods.include?("#{method}_without_synchronization") + aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 + + if instance_methods.include?("#{aliased_method}_without_synchronization#{punctuation}") raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported." end module_eval(<<-EOS, __FILE__, __LINE__) - def #{method}_with_synchronization(*args, &block) + def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) #{with}.synchronize do - #{method}_without_synchronization(*args,&block) + #{aliased_method}_without_synchronization#{punctuation}(*args,&block) end end EOS |