Created
January 20, 2010 19:42
-
-
Save riethmayer/282157 to your computer and use it in GitHub Desktop.
Null object with caller for debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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