Module: DataMapper::Ext
- Defined in:
- lib/dm-core/support/ext/hash.rb,
lib/dm-core/support/ext/array.rb,
lib/dm-core/support/ext/blank.rb,
lib/dm-core/support/ext/module.rb,
lib/dm-core/support/ext/object.rb,
lib/dm-core/support/ext/string.rb,
lib/dm-core/support/ext/try_dup.rb
Defined Under Namespace
Modules: Array, Hash, Module, Object, String
Class Method Summary collapse
-
.blank?(value) ⇒ Boolean
Determines whether the specified
value
is blank. - .try_dup(value) ⇒ Object
Class Method Details
.blank?(value) ⇒ Boolean
Determines whether the specified value
is blank.
An object is blank if it’s false, empty, or a whitespace string. For example, “”, “ ”, nil
, [], and {} are blank.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dm-core/support/ext/blank.rb', line 9 def self.blank?(value) return value.blank? if value.respond_to?(:blank?) case value when ::NilClass, ::FalseClass true when ::TrueClass, ::Numeric false when ::Array, ::Hash value.empty? when ::String value !~ /\S/ else value.nil? || (value.respond_to?(:empty?) && value.empty?) end end |