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.



6
7
8
9
# File 'lib/cistern/data/hash.rb', line 6

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

Instance Method Details

#clearObject



11
12
13
# File 'lib/cistern/data/hash.rb', line 11

def clear
  hash.clear
end

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



23
24
25
26
27
# File 'lib/cistern/data/hash.rb', line 23

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

  hash.fetch(key, *args)
end

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



15
16
17
18
19
# File 'lib/cistern/data/hash.rb', line 15

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

  hash.store(key, *args)
end