Class: Hamster::MutableHash
- Inherits:
-
Object
- Object
- Hamster::MutableHash
show all
- Extended by:
- Forwardable
- Includes:
- ReadCopyUpdate
- Defined in:
- lib/hamster/mutable_hash.rb
Instance Method Summary
(collapse)
#eql?, #initialize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hamster::ReadCopyUpdate
Instance Method Details
- (Object) delete(key)
27
28
29
30
31
32
33
34
|
# File 'lib/hamster/mutable_hash.rb', line 27
def delete(key)
old_value = nil
transform do |hash|
old_value = hash.get(key)
hash.delete(key)
end
old_value
end
|
- (Object) put(key, value = Undefined, &block)
17
18
19
|
# File 'lib/hamster/mutable_hash.rb', line 17
def put(key, value = Undefined, &block)
transform { |hash| hash.put(key, value, &block) }
end
|
- (Object) store(key, value)
21
22
23
24
|
# File 'lib/hamster/mutable_hash.rb', line 21
def store(key, value)
put(key, value)
value
end
|