Class: Hamster::MutableHash Private

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

Overview

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.

API:

  • private

Class Method Summary collapse

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

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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



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.

API:

  • private



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

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