Sha256: 4f0dc5878b19d3e5c596a589ce8d5ccd72cf0112825c4680bdc3b5b342bb6c23

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 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 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

6 entries across 6 versions & 1 rubygems

Version Path
muflax-0.5.5 lib/muflax/blank.rb
muflax-0.5.3 lib/muflax/blank.rb
muflax-0.5.2 lib/muflax/blank.rb
muflax-0.5.1 lib/muflax/blank.rb
muflax-0.5.0 lib/muflax/blank.rb
muflax-0.4.2 lib/muflax/blank.rb