aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
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
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')
-rw-r--r--activesupport/lib/active_support/core_ext/string.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/string/inquiry.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string.rb b/activesupport/lib/active_support/core_ext/string.rb
index 8fb8c31ade..72522d395c 100644
--- a/activesupport/lib/active_support/core_ext/string.rb
+++ b/activesupport/lib/active_support/core_ext/string.rb
@@ -11,3 +11,4 @@ require 'active_support/core_ext/string/output_safety'
require 'active_support/core_ext/string/exclude'
require 'active_support/core_ext/string/encoding'
require 'active_support/core_ext/string/strip'
+require 'active_support/core_ext/string/inquiry'
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