Class Hash
In: lib/hashery/stash.rb
lib/hashery/core_ext.rb
Parent: Object

Methods

create   rekey   rekey!   retrieve   to_h   to_hash   to_stash  

Public Class methods

Create a hash given an `initial_hash`.

initial_hash - Hash or hash-like object to use as priming data. block - Procedure used by initialize (e.g. default_proc).

Returns a `Hash`.

Public Instance methods

Synonym for Hash#rekey, but modifies the receiver in place (and returns it).

key_map - Hash of old key to new key. block - Procedure to convert keys, which can take just the key

          or both key and value as arguments.

Examples

  foo = { :name=>'Gavin', :wife=>:Lisa }
  foo.rekey!{ |k| k.to_s }  #=>  { "name"=>"Gavin", "wife"=>:Lisa }
  foo.inspect               #=>  { "name"=>"Gavin", "wife"=>:Lisa }

Returns `Hash`.

Synonym for Hash#rekey, but modifies the receiver in place (and returns it).

key_map - Hash of old key to new key. block - Procedure to convert keys, which can take just the key

          or both key and value as arguments.

Examples

  foo = { :name=>'Gavin', :wife=>:Lisa }
  foo.rekey!{ |k| k.to_s }  #=>  { "name"=>"Gavin", "wife"=>:Lisa }
  foo                       #=>  { "name"=>"Gavin", "wife"=>:Lisa }

Returns `Hash`.

Like fetch but returns the results of calling `default_proc`, if defined, otherwise `default`.

key - Hash key to lookup.

Returns value of Hash entry or `nil`.

to_h()

Alias for to_hash

Convert to Hash.

Convert Hash to Stash.

[Validate]