Class: ReadonlyHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/settings_hash.rb

Overview

A very simple “readonly” hash implementation. Freezes itselfs on initialization so that any attempts to change will result in a TypeError

Direct Known Subclasses

SettingsHash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#symbolize_keys

Constructor Details

#initialize(hash) ⇒ ReadonlyHash

Returns a new instance of ReadonlyHash.



23
24
25
26
# File 'lib/settings_hash.rb', line 23

def initialize(hash)
  update hash
  freeze
end

Class Method Details

.[](*args) ⇒ Object



18
19
20
# File 'lib/settings_hash.rb', line 18

def [](*args)
  new(super(*args))
end