Class Choice::LazyHash
In: lib/choice/lazyhash.rb
Parent: Hash

This class lets us get away with really bad, horrible, lazy hash accessing. Like so:

  hash = LazyHash.new
  hash[:someplace] = "somewhere"
  puts hash[:someplace]
  puts hash['someplace']
  puts hash.someplace

If you’d like, you can pass in a current hash when initializing to convert it into a lazyhash. Or you can use the .to_lazyhash method attached to the Hash object (evil!).

Methods

[]   []=   fetch   method_missing   new   store  

External Aliases

store -> old_store
  Keep the old methods around.
fetch -> old_fetch

Public Class methods

You can pass in a normal hash to convert it to a LazyHash.

Public Instance methods

Every key is stored as a string. Like a normal hash, nil is returned if the key does not exist.

Store every key as a string.

Wrapper for []=

You can use hash.something or hash.something = ‘thing’ since this is truly a lazy hash.

Wrapper for []

[Validate]