Sha256: 422bbe3ace18cd641dc90008b7647339b53fb2f3e2228ef5b221f2954ea7896c
Contents?: true
Size: 848 Bytes
Versions: 3
Compression:
Stored size: 848 Bytes
Contents
#!/usr/bin/env ruby # -*- encoding: utf-8 -*- # Copyright Freya Dorn <freya.siv.dorn@gmail.com>, 2017 # License: GNU APGLv3 (or later) <http://www.gnu.org/copyleft/gpl.html> class Object def present? ; !blank? ; end def nil_if_blank ; self.blank? ? nil : self ; end end # defaults class Object ; def blank? ; false ; 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
muflax-0.7.0 | lib/muflax/blank.rb |
muflax-0.6.1 | lib/muflax/blank.rb |
muflax-0.6.0 | lib/muflax/blank.rb |