diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-24 05:14:04 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-24 05:14:04 +0000 |
commit | df95567598677a9c109146df8531674e70c2eb80 (patch) | |
tree | f793f59e0bfa45bdf0e57ac5ff90ca5b231c0271 /activesupport/lib/active_support | |
parent | 1f4dc25250d828dd7f4c2c1c8e1d23c24c3e8d0b (diff) | |
download | rails-df95567598677a9c109146df8531674e70c2eb80.tar.gz rails-df95567598677a9c109146df8531674e70c2eb80.tar.bz2 rails-df95567598677a9c109146df8531674e70c2eb80.zip |
Added native, faster implementations of .blank? for the core types #2286 [skae]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2319 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/blank.rb | 36 |
1 files changed, 36 insertions, 0 deletions
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 0000000000..f56799bc0d --- /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 |