Skip to content

Instantly share code, notes, and snippets.

@riethmayer
Created January 20, 2010 19:42
Show Gist options
  • Save riethmayer/282157 to your computer and use it in GitHub Desktop.
Save riethmayer/282157 to your computer and use it in GitHub Desktop.
Null object with caller for debug
class NullObject
def initialize
@origin = caller.first
end
def method_missing(*args, &block)
self
end
def nil?; true; end
def to_s; ""; end
end
def Maybe(value)
value.nil? ? NullObject.new : value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment