Class: Hamster::MutableHash Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

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

Class Method Details

.[](pairs = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/hamster/mutable_hash.rb', line 9

def self.[](pairs = {})
  MutableHash.new(Hash[pairs])
end

Instance Method Details

#delete(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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