Sha256: 58d7c2f02f5d469d36db6470336dbd8d128e24a5bb6c42e07c4e058eb3092b47

Contents?: true

Size: 708 Bytes

Versions: 62

Compression:

Stored size: 708 Bytes

Contents

class Object
  # An object is blank if it's nil, empty, or a whitespace string.
  # For example, "", "   ", nil, [], and {} are blank.
  #
  # This simplifies
  #   if !address.nil? && !address.empty?
  # to
  #   if !address.blank?
  def blank?
    respond_to?(:empty?) ? empty? : !self
  end
end

class NilClass #:nodoc:
  def blank?
    true
  end
end

class FalseClass #:nodoc:
  def blank?
    true
  end
end

class TrueClass #:nodoc:
  def blank?
    false
  end
end

class Array #:nodoc:
  alias_method :blank?, :empty?
end

class Hash #:nodoc:
  alias_method :blank?, :empty?
end

class String #:nodoc:
  def blank?
    self !~ /\S/
  end
end

class Numeric #:nodoc:
  def blank?
    false
  end
end

Version data entries

62 entries across 62 versions & 8 rubygems

Version Path
automateit-0.71230 lib/inactive_support/core_ext/blank.rb
automateit-0.80116 lib/inactive_support/core_ext/blank.rb
eeml-0.0.2 lib/blank.rb
eeml-0.0.1 lib/blank.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
strokedb-0.0.2 lib/util/ext/blank.rb
strokedb-0.0.2.1 lib/util/ext/blank.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/blank.rb