Created
September 23, 2013 20:43
-
-
Save mattsnyder/6676657 to your computer and use it in GitHub Desktop.
NullObject based on Avdi Grimm's Confident Code talk. http://devblog.avdi.org/2011/05/30/null-objects-and-falsiness/
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 ### SETS ORIGIN FOR INSPECT INFO | |
end | |
def method_missing(*args, &block) | |
self | |
end | |
def nil?; true; end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment