Last active
August 29, 2015 14:01
-
-
Save danott/a94ce00be06a509d553d to your computer and use it in GitHub Desktop.
The Null Object Pattern as an ActiveSupport Concern.
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
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