Tim Case, I think you misunderstood Jamis Buck’s article. He never said DI should never be used in Ruby or that it’s not a useful concept. On the contrary, he actually uses it and encourages it. Here is a direct quote from the article:
So, is there no room for DI in Ruby? There definitely is. I use DI nearly every day in Ruby, but I do not use a DI framework. Ruby itself has sufficient power to represent any day-to-day DI idioms you need. Consider this one:
Here, B declares a factory method for generating new client objects. Because Ruby lets you declare default values for method arguments, you can let the default client implementation be A, which is the common case. But for testing, you can easily inject a mock into that method by passing an explicit parameter.
That’s one of the ways I use DI in Ruby, and it makes testing a lot easier and cleaner. Here are some more articles about the same concept:
Nothing is more pleasing than beautiful code. And nothing is more heart-breaking than watching beautiful code get…www.sandimetz.com
Note: This is going to sound crazy at first, but bear with me. The current best-practice for writing rails code…jamesgolick.com
I was wondering what do we, rubyists, think about dependency injection these days as I remember some discussions about…solnic.eu
I recently wrote some code to interface with Stripe's webhooks. After looking at the code and tests, I decided I needed…brandonhilkert.com