Sha256: df0534661d3f0e7795e68b9543fa568f3cc851de88bdbf8832113a3e60840bb2

Contents?: true

Size: 437 Bytes

Versions: 3

Compression:

Stored size: 437 Bytes

Contents

# frozen_string_literal: true

class Pathname
  # Returns the receiver if the named file exists otherwise returns +nil+.
  # <tt>pathname.existence</tt> is equivalent to
  #
  #    pathname.exists? ? pathname : nil
  #
  # For example, something like
  #
  #   content = pathname.read if pathname.exist?
  #
  # becomes
  #
  #   content = pathname.existence&.read
  #
  # @return [Pathname]
  def existence
    self if exist?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activesupport-7.0.0.rc3 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.0.rc2 lib/active_support/core_ext/pathname/existence.rb
activesupport-7.0.0.rc1 lib/active_support/core_ext/pathname/existence.rb