Created
March 30, 2017 11:49
-
-
Save j4zzcat/d6c62563dda34f749c7f22aee97892a3 to your computer and use it in GitHub Desktop.
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
file utils.rb: | |
-------------- | |
require 'webrick' | |
module Utils | |
WEBrick::HTTPStatus::StatusMessage.each do | k, v | | |
self.const_set "HTTP_#{k}_#{v.upcase.tr ' -', '_'}".to_sym, k | |
end | |
end | |
file app.rb: | |
------------ | |
require 'utils' | |
puts Utils::HTTP_200_OK. # => 200 | |
puts Utils::HTTP_201_CREATED # => 201 | |
# etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment