Skip to content

Instantly share code, notes, and snippets.

@nebolsin
Created February 15, 2011 16:45
Show Gist options
  • Select an option

  • Save nebolsin/827782 to your computer and use it in GitHub Desktop.

Select an option

Save nebolsin/827782 to your computer and use it in GitHub Desktop.
Rails 2.3.10 ActiveSupport::StringInquirer class
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