Sha256: 58a66903c3c22210175ee0a1f59639c6c4444ee59cac8abb5c8986b6b4da5e54

Contents?: true

Size: 999 Bytes

Versions: 17

Compression:

Stored size: 999 Bytes

Contents

module Spruz
  module Blank
    module Object
      def blank?
        respond_to?(:empty?) ? empty? : !self
      end

      def present?
        !blank?
      end
    end

    module NilClass
      def blank?
        true
      end
    end

    module FalseClass
      def blank?
        true
      end
    end

    module TrueClass
      def blank?
        false
      end
    end

    module Array
      def self.included(modul)
        modul.module_eval do
          alias_method :blank?, :empty?
        end
      end
    end

    module Hash
      def self.included(modul)
        modul.module_eval do
          alias_method :blank?, :empty?
        end
      end
    end

    module String
      def blank?
        self !~ /\S/
      end
    end

    module Numeric
      def blank?
        false
      end
    end
  end

  unless Object.respond_to?(:blank?)
    for k in Blank.constants
      Object.const_get(k).class_eval do
        include Blank.const_get(k)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spruz-0.2.13 lib/spruz/xt/blank.rb
spruz-0.2.12 lib/spruz/xt/blank.rb
spruz-0.2.11 lib/spruz/xt/blank.rb
spruz-0.2.10 lib/spruz/xt/blank.rb
spruz-0.2.9 lib/spruz/xt/blank.rb
spruz-0.2.8 lib/spruz/xt/blank.rb
spruz-0.2.7 lib/spruz/xt/blank.rb
spruz-0.2.6 lib/spruz/xt/blank.rb
spruz-0.2.5 lib/spruz/xt/blank.rb
spruz-0.2.2 lib/spruz/xt/blank.rb
spruz-0.2.1 lib/spruz/xt/blank.rb
spruz-0.2.0 lib/spruz/xt/blank.rb
spruz-0.1.5 lib/spruz/xt/blank.rb
spruz-0.1.3 lib/spruz/xt/blank.rb
spruz-0.1.2 lib/spruz/xt/blank.rb
spruz-0.1.1 lib/spruz/xt/blank.rb
spruz-0.1.0 lib/spruz/xt/blank.rb