Class: Hamster::MutableHash

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hamster::ReadCopyUpdate

Instance Method Details

#delete(key) ⇒ Object



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

#put(key, value = Undefined, &block) ⇒ Object



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

#store(key, value) ⇒ Object



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

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