Sha256: 387d96051503bef6d570f42db31f44b8548316146c05b39a0dcae75f9aa54e9e
Contents?: true
Size: 832 Bytes
Versions: 2
Compression:
Stored size: 832 Bytes
Contents
#!/usr/bin/env ruby # -*- encoding: utf-8 -*- # Copyright Steffie Dorn <mail@muflax.com>, 2017 # License: GNU APGLv3 (or later) <http://www.gnu.org/copyleft/gpl.html> class Object def blank? ; !self ; end def present? ; !blank? ; end def nil_if_blank ; self.blank? ? nil : self ; end end class NilClass ; def blank? ; true ; end ; end class FalseClass ; def blank? ; true ; end ; end class TrueClass ; def blank? ; false ; end ; end class Numeric ; def blank? ; false ; end ; end class Time ; def blank? ; false ; end ; end class Array ; alias_method :blank?, :empty? ; end class Hash ; alias_method :blank?, :empty? ; end require "fast_blank" # class String # BLANK_RE = /\A[[:space:]]*\z/ # def blank? # empty? || BLANK_RE.match?(self) # end # end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
muflax-0.4.1 | lib/muflax/blank.rb |
muflax-0.4.0 | lib/muflax/blank.rb |