Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created September 23, 2013 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsnyder/6676657 to your computer and use it in GitHub Desktop.
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/
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