Class: Hamster::MutableHash

Inherits:
Object
  • Object
show all
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


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

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


12
13
14
# File 'lib/hamster/mutable_hash.rb', line 12

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

#store(key, value) ⇒ Object Also known as: []=


16
17
18
19
# File 'lib/hamster/mutable_hash.rb', line 16

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