Class: Hamster::MutableHash

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ReadCopyUpdate
Defined in:
lib/hamster/mutable_hash.rb

Instance Method Summary (collapse)

Methods included from ReadCopyUpdate

#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)



24
25
26
27
28
29
30
31
# File 'lib/hamster/mutable_hash.rb', line 24

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)



14
15
16
# File 'lib/hamster/mutable_hash.rb', line 14

def put(key, value = Undefined, &block)
  transform { |hash| hash.put(key, value, &block) }
end

- (Object) store(key, value)



18
19
20
21
# File 'lib/hamster/mutable_hash.rb', line 18

def store(key, value)
  put(key, value)
  value
end