Right. And I only posted a cut down version of the code. NilObject is
defined in the full version.
@nested = nested || NilObject.new
won’t work, and is probably unnecessary.
Interesting. Let me make certain you understand my intentions first.
NilObject looks like this:
class NilObject
def method_missing(name, *params); end
end
It just swallows messages. It is an implementation of the Introduce Null
Object refactor Introduce Special Case This means
that I don’t have to continuously repeat checks for nil. It’s explained
a bit better here Introduce Null Object
This is a concept that has come straight out of Java so I’m interested
if there is a more ruby way of doing such things.
is probably enough, unless you really want to be able to pass false to
indicate no nested, which would be a strange interface for a ruby
method I think. But it that’s what’s actually desired, it should be