diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/blank.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/blank.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/blank.rb b/activesupport/lib/active_support/core_ext/blank.rb index 791cdc5705..f7fbea3e89 100644 --- a/activesupport/lib/active_support/core_ext/blank.rb +++ b/activesupport/lib/active_support/core_ext/blank.rb @@ -1,4 +1,16 @@ -# The methods here are provided to speed up function blank? in class Object +class Object #:nodoc: + # "", " ", nil, [], and {} are blank + def blank? + if respond_to?(:empty?) && respond_to?(:strip) + empty? or strip.empty? + elsif respond_to?(:empty?) + empty? + else + !self + end + end +end + class NilClass #:nodoc: def blank? true @@ -35,4 +47,4 @@ class Numeric #:nodoc: def blank? false end -end +end
\ No newline at end of file |