Guides to the core and standard libraries, as well as selected Rubygems.
Following on to the episodes about #fetch, today's episode answers the question: what do we do when we want the same defaulting behavior everwhere a Hash is used?
This episode focuses on OpenStruct, which makes it easy to create ad-hoc value objects from hashes.
In this episode we look at the Tempfile standard library, and how it can facilitate communicating with subprocesses.
In previous episodes we've used the Struct class in passing to quickly construct classes. This time, we put Struct in the spotlight, and put it through its paces. You'll want …
In this final installment on the #fetch method we look at #fetch beyond Hash; #fetch with nested hashes; re-using default blocks; and more.
How to use Hash#fetch to provide defaults for missing keys, and why you might prefer that to other techniques for defaulting values.
Hash#fetch is one of my favorite methods. In this episode, I take a look at using it to assert the existence of hash keys.