aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-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