diff options
author | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-12-28 16:26:26 +0200 |
---|---|---|
committer | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-12-28 16:52:14 +0200 |
commit | 37513b10a8c2e43885bf52e1b2f7fd9d4f106901 (patch) | |
tree | c7ab2adda70464f9003a3ba0b75558cb21c9af99 /activesupport/lib | |
parent | f66f483d900dfbcb6dfa2df9c6188663489475ab (diff) | |
download | rails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.tar.gz rails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.tar.bz2 rails-37513b10a8c2e43885bf52e1b2f7fd9d4f106901.zip |
Extracted blank matcher regexp to constant
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/blank.rb | 4 |
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 |