Class StaticHash
In: lib/facet/statichash.rb
Parent: Hash

Description

A Hash object which raises an error if any previously-defined key attempts to be set again.

Synopsis

  foo = StaticHash.new
  foo['name'] = 'Tom'    #=> 'Tom'
  foo['age']  = 30       #=> 30
  foo['name'] = 'Bob'

produces

  Error: StaticHash has value for key 'name' in object:
      {"name"=>"Tom", "age"=>30} (RuntimeError)

Author(s)

  • Gavin Kistner

Methods

[]=  

Constants

VERSION = '1.0.0'

Public Instance methods

Set a value for a key; raises an error if that key already exists with a different value.

[Validate]