aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/blank.rb
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxedconsulting.com>2015-09-21 12:59:00 +0100
committerAndrew White <andrew.white@unboxedconsulting.com>2015-09-21 12:59:00 +0100
commitb3eac823006eb6a346f88793aabef28a6d4f928c (patch)
tree0eb74be3a0cc442623aa57aefea13439635bad8b /activesupport/lib/active_support/core_ext/date/blank.rb
parentcd2c0adb8aad6fef44025ea97f67cb9e21e52dcf (diff)
downloadrails-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/date/blank.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/blank.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/blank.rb b/activesupport/lib/active_support/core_ext/date/blank.rb
new file mode 100644
index 0000000000..71627b6a6f
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/date/blank.rb
@@ -0,0 +1,12 @@
+require 'date'
+
+class Date #:nodoc:
+ # No Date is blank:
+ #
+ # Date.today.blank? # => false
+ #
+ # @return [false]
+ def blank?
+ false
+ end
+end