diff options
author | Andrew White <andrew.white@unboxedconsulting.com> | 2015-09-21 12:59:00 +0100 |
---|---|---|
committer | Andrew White <andrew.white@unboxedconsulting.com> | 2015-09-21 12:59:00 +0100 |
commit | b3eac823006eb6a346f88793aabef28a6d4f928c (patch) | |
tree | 0eb74be3a0cc442623aa57aefea13439635bad8b /activesupport/lib/active_support/core_ext/object/blank.rb | |
parent | cd2c0adb8aad6fef44025ea97f67cb9e21e52dcf (diff) | |
download | rails-b3eac823006eb6a346f88793aabef28a6d4f928c.tar.gz rails-b3eac823006eb6a346f88793aabef28a6d4f928c.tar.bz2 rails-b3eac823006eb6a346f88793aabef28a6d4f928c.zip |
Short-circuit `blank?` on date and time values
The concept of a blank date or time doesn't make sense so we can short
circuit the calls for `blank?` on these classes to gain small speed boost.
Fixes #21657
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/blank.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/blank.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index a294228979..039c50a4a2 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -127,3 +127,14 @@ class Numeric #:nodoc: false end end + +class Time #:nodoc: + # No Time is blank: + # + # Time.now.blank? # => false + # + # @return [false] + def blank? + false + end +end |