diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 7411beddefd23ed250180fcb66b0a4c0a613ccb9..3786ee22beee8539e0bb0df63f9530095e9cb4f6 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added native, faster implementations of .blank? for the core types #2286 [skae] + * Fixed clean logger to work with Ruby 1.8.3 Logger class #2245 * Fixed memory leak with Active Record classes when Dependencies.mechanism = :load #1704 [c.r.mcgrath@gmail.com] diff --git a/activesupport/lib/active_support/core_ext/blank.rb b/activesupport/lib/active_support/core_ext/blank.rb new file mode 100644 index 0000000000000000000000000000000000000000..f56799bc0d349c2d2bddebc72c033d95c2ec15b9 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/blank.rb @@ -0,0 +1,36 @@ +# The methods here are provided to speed up function blank? in class Object +class NilClass + def blank? + true + end +end + +class FalseClass + def blank? + true + end +end + +class TrueClass + def blank? + false + end +end + +class Array + alias_method :blank?, :empty? +end + +class Hash + alias_method :blank?, :empty? +end + +class String + def blank? + empty? || strip.empty? + end +end + +class Numeric + alias_method :blank?, :zero? +end \ No newline at end of file