aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-12-28 16:26:26 +0200
committerPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-12-28 16:52:14 +0200
commit37513b10a8c2e43885bf52e1b2f7fd9d4f106901 (patch)
treec7ab2adda70464f9003a3ba0b75558cb21c9af99 /activesupport
parentf66f483d900dfbcb6dfa2df9c6188663489475ab (diff)
downloadrails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.tar.gz
rails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.tar.bz2
rails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.zip
Extracted blank matcher regexp to constant
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index f9ff4d9567..a4b3234fda 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -83,6 +83,8 @@ class Hash
end
class String
+ BLANK_MATCHER = /\A[[:space:]]*\z/
+
# A string is blank if it's empty or contains whitespaces only:
#
# ''.blank? # => true
@@ -90,7 +92,7 @@ class String
# ' '.blank? # => true
# ' something here '.blank? # => false
def blank?
- self =~ /\A[[:space:]]*\z/
+ self =~ BLANK_MATCHER
end
end