Created
December 30, 2014 16:53
-
-
Save inf0rmer/147dd9d5c52f2ed77aae to your computer and use it in GitHub Desktop.
Automatically generating ~60 Blanket::Exception subclasses
This file contains hidden or 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
STATUSES.each_pair do |code, message| | |
klass = Class.new(Exception) do | |
send(:define_method, :message) {"#{code ? "#{code} " : ''}#{message}"} | |
end | |
klass_constant = const_set message.delete(' \-\''), klass | |
Exceptions::EXCEPTIONS_MAP[code] = klass_constant | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment