aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/blank.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/blank.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/blank.rb36
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