"Unobtrusive Ruby" in Practice
practicingruby.com
practicingruby.com
Looking at the code: I'd be wary of chaining << to a custom class since it's a source of error if << does something clever/extra and does not return self.
It's OK to pass a Class to an IoC container (my own Ruby version: https://github.com/wiecklabs/harbor/blob/master/lib/harbor/c...), but if you're actually injecting them into your objects that feels wrong.
I really wish I were more eloquent and could explain why it feels that way. :-/
I guess perhaps it just feels a bit primitive to be managing dependencies manually in the manner of the example?
That said, I'd rather work with code that at least attempts to break out dependencies like in the example, making testing and re-use much simpler over code that's tightly coupled any day of the week.
EDIT: Just to be clear, after reading further, nit-picks aside, this really is a great, eloquent article that makes several important concepts very accessible. Very nicely done IMO.
But in Ruby, classes are objects with certain methods to create instances of themselves, aren't they?
The point here is simply that you should pass the object you directly want to work with, not a class that can be used to generate that object. So if the business of your method is to actually operate on a class object, that's fine. But if you're calling new() on that class, probably not as fine.