Sha256: 34b5d37588a64d5a5a3154a4893d78a6ef0b15682a0150ef4755f84bf9add193

Contents?: true

Size: 936 Bytes

Versions: 59

Compression:

Stored size: 936 Bytes

Contents

unless nil.respond_to?(:blank?)
  class Object
    def blank?
      respond_to?(:empty?) ? empty? : !self
    end

    # An object is present if it's not blank.
    #
    # @return [true, false]
    def present?
      !blank?
    end unless Object.instance_methods.include? :present?

    def presence
      self if present?
    end  unless Object.instance_methods.include? :presence
  end

  class NilClass #:nodoc:
    def blank?
      true
    end
  end
  
  class FalseClass #:nodoc:
    def blank?
      true
    end
  end
  
  class TrueClass #:nodoc:
    def blank?
      false
    end
  end
  
  class Array #:nodoc:
    alias_method :blank?, :empty?
  end
  
  class Hash #:nodoc:
    alias_method :blank?, :empty?
  end
  
  class String #:nodoc:
    def blank?
      self !~ /\S/
    end
  end
  
  class Numeric #:nodoc:
    def blank?
      false
    end
  end  
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
cloudinary-2.2.0 lib/cloudinary/missing.rb
cloudinary-2.1.2 lib/cloudinary/missing.rb
cloudinary-2.0.2 lib/cloudinary/missing.rb
cloudinary-2.0.1 lib/cloudinary/missing.rb
cloudinary-2.0.0 lib/cloudinary/missing.rb
cloudinary-1.29.0 lib/cloudinary/missing.rb
cloudinary-1.28.0 lib/cloudinary/missing.rb
cloudinary-1.27.0 lib/cloudinary/missing.rb
cloudinary-1.26.0 lib/cloudinary/missing.rb
cloudinary-1.25.0 lib/cloudinary/missing.rb
cloudinary-1.24.0 lib/cloudinary/missing.rb
cloudinary-1.23.0 lib/cloudinary/missing.rb
cloudinary-1.22.0 lib/cloudinary/missing.rb
cloudinary-1.21.0 lib/cloudinary/missing.rb
cloudinary-1.20.0 lib/cloudinary/missing.rb
cloudinary-1.19.0 lib/cloudinary/missing.rb
cloudinary-1.18.1 lib/cloudinary/missing.rb
cloudinary-1.18.0 lib/cloudinary/missing.rb
cloudinary-1.17.1 lib/cloudinary/missing.rb
cloudinary-1.17.0 lib/cloudinary/missing.rb