Class: CleanHash::MutexHash
- Inherits:
-
Object
- Object
- CleanHash::MutexHash
- Defined in:
- lib/clean-hash/mutex_hash.rb
Constant Summary collapse
- MUTEX =
Mutex.new
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize(name = nil) ⇒ MutexHash
constructor
A new instance of MutexHash.
Constructor Details
#initialize(name = nil) ⇒ MutexHash
Returns a new instance of MutexHash.
6 7 8 |
# File 'lib/clean-hash/mutex_hash.rb', line 6 def initialize name=nil @data ||= {} end |
Instance Method Details
#[](name) ⇒ Object
10 11 12 |
# File 'lib/clean-hash/mutex_hash.rb', line 10 def [] name @data[name.to_sym] end |
#[]=(name, value) ⇒ Object
14 15 16 17 18 |
# File 'lib/clean-hash/mutex_hash.rb', line 14 def []= name, value MUTEX.synchronize do @data[name.to_sym] = value end end |