aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2011-04-18 10:56:37 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-04-18 10:57:38 +0200
commit39372964d245ba7077515a698eaf71cb534800fe (patch)
tree397b59003c3a9171bd6727a7651cdbc64e8c7881 /activesupport/lib/active_support/core_ext/string
parent389d15ef139e50696b274f2d61dd309ba2632877 (diff)
downloadrails-39372964d245ba7077515a698eaf71cb534800fe.tar.gz
rails-39372964d245ba7077515a698eaf71cb534800fe.tar.bz2
rails-39372964d245ba7077515a698eaf71cb534800fe.zip
Add String#inquiry as a convenience method for turning a string into a StringInquirer object [DHH]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string')
-rw-r--r--activesupport/lib/active_support/core_ext/string/inquiry.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/inquiry.rb b/activesupport/lib/active_support/core_ext/string/inquiry.rb
new file mode 100644
index 0000000000..604f3bf4dc
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/string/inquiry.rb
@@ -0,0 +1,13 @@
+require 'active_support/string_inquirer'
+
+class String
+ # Wraps the current string in the ActiveSupport::StringInquirer class,
+ # which gives you a prettier way to test for equality. Example:
+ #
+ # env = "production".inquiry
+ # env.production? # => true
+ # env.development? # => false
+ def inquiry
+ ActiveSupport::StringInquirer.new(self)
+ end
+end