mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #9784 from vipulnsward/change_from_blank_to_empty_on_string
Change from blank? to empty? on obvious string values to save extra calls
This commit is contained in:
commit
9c4c05fc82
1 changed files with 4 additions and 4 deletions
|
@ -161,7 +161,7 @@ module ActiveRecord
|
|||
|
||||
def value_to_date(value)
|
||||
if value.is_a?(String)
|
||||
return nil if value.blank?
|
||||
return nil if value.empty?
|
||||
fast_string_to_date(value) || fallback_string_to_date(value)
|
||||
elsif value.respond_to?(:to_date)
|
||||
value.to_date
|
||||
|
@ -172,14 +172,14 @@ module ActiveRecord
|
|||
|
||||
def string_to_time(string)
|
||||
return string unless string.is_a?(String)
|
||||
return nil if string.blank?
|
||||
return nil if string.empty?
|
||||
|
||||
fast_string_to_time(string) || fallback_string_to_time(string)
|
||||
end
|
||||
|
||||
def string_to_dummy_time(string)
|
||||
return string unless string.is_a?(String)
|
||||
return nil if string.blank?
|
||||
return nil if string.empty?
|
||||
|
||||
dummy_time_string = "2000-01-01 #{string}"
|
||||
|
||||
|
@ -192,7 +192,7 @@ module ActiveRecord
|
|||
|
||||
# convert something to a boolean
|
||||
def value_to_boolean(value)
|
||||
if value.is_a?(String) && value.blank?
|
||||
if value.is_a?(String) && value.empty?
|
||||
nil
|
||||
else
|
||||
TRUE_VALUES.include?(value)
|
||||
|
|
Loading…
Reference in a new issue