Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/has_mutex.rb
Class Method Summary collapse
Class Method Details
.has_mutex(key = :id) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/has_mutex.rb', line 3 def self.has_mutex key = :id @@mutex_table = {} define_method :mutex do @@mutex_table[read_attribute(key)] ||= Mutex.new end define_method :delete_mutex do @@mutex_table.delete read_attribute(key) end delegate :synchronize, to: :mutex end |