Sha256: be9c8b12798edf634f9fffb1bb506e6eccb45ed6e419b1d79fe4028f44806c05

Contents?: true

Size: 658 Bytes

Versions: 12

Compression:

Stored size: 658 Bytes

Contents

class Object #:nodoc:
  # "", "   ", nil, [], and {} are blank
  def blank?
    if respond_to?(:empty?) && respond_to?(:strip)
      empty? or strip.empty?
    elsif respond_to?(:empty?)
      empty?
    else
      !self
    end
  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?
    empty? || strip.empty?
  end
end

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

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
activesupport-1.4.2 lib/active_support/core_ext/blank.rb
activesupport-1.3.1 lib/active_support/core_ext/blank.rb
activesupport-1.4.1 lib/active_support/core_ext/blank.rb
activesupport-1.3.0 lib/active_support/core_ext/blank.rb
activesupport-1.4.0 lib/active_support/core_ext/blank.rb
monetra-ruby-0.0.6 lib/monetra/active_support/core_ext/blank.rb
radiant-0.6.1 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.0 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.3 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
radiant-0.6.2 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
rq-3.3.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
rq-3.4.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb