forked from rails/rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 rails#21657
- Loading branch information
Showing
7 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'active_support/core_ext/date/acts_like' | ||
require 'active_support/core_ext/date/blank' | ||
require 'active_support/core_ext/date/calculations' | ||
require 'active_support/core_ext/date/conversions' | ||
require 'active_support/core_ext/date/zones' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'date' | ||
|
||
class Date #:nodoc: | ||
# No Date is blank: | ||
# | ||
# Date.today.blank? # => false | ||
# | ||
# @return [false] | ||
def blank? | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require 'active_support/core_ext/date_time/acts_like' | ||
require 'active_support/core_ext/date_time/blank' | ||
require 'active_support/core_ext/date_time/calculations' | ||
require 'active_support/core_ext/date_time/conversions' | ||
require 'active_support/core_ext/date_time/zones' |
12 changes: 12 additions & 0 deletions
12
activesupport/lib/active_support/core_ext/date_time/blank.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'date' | ||
|
||
class DateTime #:nodoc: | ||
# No DateTime is ever blank: | ||
# | ||
# DateTime.now.blank? # => false | ||
# | ||
# @return [false] | ||
def blank? | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters