From 37513b10a8c2e43885bf52e1b2f7fd9d4f106901 Mon Sep 17 00:00:00 2001 From: Paul Nikitochkin Date: Sat, 28 Dec 2013 16:26:26 +0200 Subject: Extracted blank matcher regexp to constant --- activesupport/lib/active_support/core_ext/object/blank.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3