Sha256: e23aa2d479aed1a431fd61bacfb4b9148c4c82d427a764731c532016f4930100

Contents?: true

Size: 702 Bytes

Versions: 6

Compression:

Stored size: 702 Bytes

Contents

# partialy extracted from
# https://github.com/rails/rails/blob/5-0-stable/activesupport/lib/active_support/core_ext/object/blank.rb

class Object
  def blank?
    !self
  end

  def empty?
    blank?
  end

  def present?
    !blank?
  end
end

class NilClass
  def blank?
    true
  end
end

class FalseClass
  def blank?
    true
  end
end

class TrueClass
  def blank?
    false
  end
end

class Array
  def blank?
    self.length == 0
  end
end

class Hash
  def blank?
    self.keys.length == 0
  end
end

class Numeric
  def blank?
    false
  end
end

class Time
  def blank?
    false
  end
end

class String
  def blank?
    return true if self.length == 0

    !(self =~ /[^\s]/)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./lib/overload/blank.rb
lux-fw-0.5.36 ./lib/overload/blank.rb
lux-fw-0.5.35 ./lib/overload/blank.rb
lux-fw-0.5.34 ./lib/overload/blank.rb
lux-fw-0.5.33 ./lib/overload/blank.rb
lux-fw-0.5.32 ./lib/overload/blank.rb