Sha256: 32dd6866594f1309b6ec8073aa705d3d8938b81b04b5c333f7776d2b753514da

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

require "not_blank/version"

module NotBlank
  module Object
    def nb
      self
    end
  end

  module Enumerable
    def nb
      (a = map(&:nb).compact).empty? ? nil : a
    end
  end

  module Hash
    def nb
      (h = reject { |k,v| v.nb.nil? }).empty? ? nil : h
    end
  end

  module FalseClass
    def nb
      nil
    end
  end

  module String
    def nb
      (strip == "") ? nil : self
    end
  end

  def self.setup
    ::Object.send :include, Object
    ::Hash.send :include, Hash
    ::Enumerable.send :include, Enumerable
    ::Array.send :include, Enumerable
    ::FalseClass.send :include, FalseClass
    ::String.send :include, String
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
not_blank-0.0.1 lib/not_blank.rb