Skip to content

Instantly share code, notes, and snippets.

@danott
Last active August 29, 2015 14:01
Show Gist options
  • Save danott/a94ce00be06a509d553d to your computer and use it in GitHub Desktop.
Save danott/a94ce00be06a509d553d to your computer and use it in GitHub Desktop.
The Null Object Pattern as an ActiveSupport Concern.
module NullObject
extend ActiveSupport::Concern
included do
const_set("Null#{name}", Class.new)
end
module ClassMethods
def null
const_get("Null#{name}").new
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment