Tag
Your search for ruby returned 13 results.
How to convert a Ruby struct to a hash
Use inject! (more…)
Incremental Design — A conversation with a Designer and a Developer at RailsConf 2013
Here is my Rails Conf 2013 talk! Developers: how many times have you had to completely rip out your hard earned code for a totally new site design? Designers: how many times has a re-design taken 4 times as long as the developer said it would and not looked good in the end? Change all that by using an incremental approach to design. Set up your code to change ...
DRY up Rspec with tap!
I'm a big fan of keeping Rspec DRY. Mostly, because it hurts my heart to have to write the same thing twice. It huuuurts. Here's a great article on code reuse in Rspec. A scenario I struggle with DRYing up: I'd like to either stub! or call should_receive on a method and sometimes return a value. Previously, I would still have to write the stub! or should_receive ...
Recursively convert a Ruby hash to OpenStruct
I love OpenStruct. Like love love. The only reason I wouldn't marry it is that it won't recursively convert a nested hash to OpenStruct. So I wrote a hash extension to do just that. Wip out your credit cards, our wedding registry is forth coming. (more…)
Extend Ruby hash to return all keys as symbols
It is sometimes useful to force all hash keys to be symbols, especially in a situation where you can't use HashWithIndifferentAccess. (more…)