Class: Cistern::Data::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/cistern/data/hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(_options = {}, &default) ⇒ Hash

Returns a new instance of Hash.



4
5
6
7
# File 'lib/cistern/data/hash.rb', line 4

def initialize(_options = {}, &default)
  @hash    = {}
  @default = default
end

Instance Method Details

#clearObject



9
10
11
# File 'lib/cistern/data/hash.rb', line 9

def clear
  hash.clear
end

#fetch(key, *args) ⇒ Object Also known as: []



21
22
23
24
25
# File 'lib/cistern/data/hash.rb', line 21

def fetch(key, *args)
  assign_default(key)

  hash.fetch(key, *args)
end

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



13
14
15
16
17
# File 'lib/cistern/data/hash.rb', line 13

def store(key, *args)
  assign_default(key)

  hash.store(key, *args)
end