Created
November 18, 2014 01:21
-
-
Save tastycode/09034813f09d17294c09 to your computer and use it in GitHub Desktop.
My null object
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 Null | |
def !@ | |
false | |
end | |
def nil? | |
true | |
end | |
def present? | |
false | |
end | |
def presence | |
nil | |
end | |
def empty? | |
true | |
end | |
def method_missing(name, *) | |
self | |
end | |
def respond_to?(name) | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment