Sha256: bca493bb9116f73a4f5a45c9375f57cc57978fc20a89027c37021c0aad8e493f

Contents?: true

Size: 383 Bytes

Versions: 5

Compression:

Stored size: 383 Bytes

Contents

begin
  # Add support for Object#presence:
  require 'active_support/core_ext/object/blank'

rescue LoadError => e
  Object.class_eval do
    unless respond_to?(:present?)
      def present?
        !!presence
      end
    end

    unless respond_to?(:presence)
      def presence
        return nil if respond_to?(:empty?) ? empty? : !self
        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hungry-0.2.0 lib/support/presence.rb
hungry-0.1.5 lib/support/presence.rb
hungry-0.1.4 lib/support/presence.rb
hungry-0.1.3 lib/support/presence.rb
hungry-0.1.2 lib/support/presence.rb