2008-06-04 16:02:51 -04:00
|
|
|
module ActiveSupport
|
2008-09-03 12:58:47 -04:00
|
|
|
# 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?
|
|
|
|
#
|
2008-06-04 16:06:32 -04:00
|
|
|
class StringInquirer < String
|
2008-06-04 16:02:51 -04:00
|
|
|
def method_missing(method_name, *arguments)
|
2008-10-30 12:45:30 -04:00
|
|
|
if method_name.to_s[-1,1] == "?"
|
2008-06-04 16:02:51 -04:00
|
|
|
self == method_name.to_s[0..-2]
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
2008-06-03 18:44:56 -04:00
|
|
|
end
|
|
|
|
end
|
2008-06-04 16:02:51 -04:00
|
|
|
end
|