Sha256: 570414246d2ae9410f54322ebbe6ed1a3ced2c78eca1f1ec48732f6b1a435b46

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

begin
  File.open(__FILE__, :mode => 'r'){}
rescue TypeError
  require 'backports/tools'

  def open_with_options_hash(file, mode = nil, perm_or_options = Backports::Undefined)
    mode, perm = Backports.combine_mode_perm_and_option(mode, perm_or_options)
    perm ||= 0666 # Avoid error on Rubinius, see issue #52
    if block_given?
      open_without_options_hash(file, mode, perm){|f| yield f}
    else
      open_without_options_hash(file, mode, perm)
    end
  end

  class << File
    Backports.alias_method_chain self, :open, :options_hash
  end
end

if RUBY_VERSION < '1.9'
  require 'backports/tools'

  Backports.convert_first_argument_to_path File, :open
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backports-3.6.0 lib/backports/1.9.1/file/open.rb
backports-3.5.0 lib/backports/1.9.1/file/open.rb
backports-3.4.1 lib/backports/1.9.1/file/open.rb