Created
December 9, 2008 07:26
-
-
Save mischa/33829 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
module ActiveSupport | |
# Wrapping a string in this class gives you a prettier way to test | |
# for equality. The value returned by <tt>Rails.env</tt> is wrapped | |
# in a StringInquirer object so instead of calling this: | |
# | |
# Rails.env == "production" | |
# | |
# you can call this: | |
# | |
# Rails.env.production? | |
# | |
class StringInquirer < String | |
def method_missing(method_name, *arguments) | |
if method_name.to_s[-1,1] == "?" | |
self == method_name.to_s[0..-2] | |
else | |
super | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment