Class | Hashery::CastingHash |
In: |
lib/hashery/casting_hash.rb
|
Parent: | CRUDHash |
CastingHash is just like CRUDHash, except that both keys and values can be passed through casting procedures.
Like `new` but can take a priming Hash or Array-pairs.
hash - Hash-like object.
Examples
CastingHash[:a,1,:b,2]
Returns `CastingHash`.
Unlike traditional Hash a CastingHash‘s block argument coerces key/value pairs when store is called.
default - Default value. cast_proc - Casting procedure.
Set `cast_proc`. This procedure must take two arguments (`key, value`) and return the same.
proc - Casting procedure.
Returns proc.
CRUD method for create and update. Unlike the parent class the key, value pair are passed threw the cast_proc before being set in the underlying hash table.
key - Key of entry. value - Value of entry.
Returns the value.