Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/tempfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ class << self
# object will be automatically closed after the block terminates.
# The call returns the value of the block.
#
# Unlike Tempfile.create, Tempfile.open when called with a block
# does not unlink the temporary file when the block exits. When using
# Tempfile.open, the temporary file is not unlinked from the file
# system unless Tempfile#unlink or Tempfile#close! is called directly,
# or until the Tempfile instance is garbage collected. Due to this,
# most callers of Tempfile.open with a block should use Tempfile.create instead.
#
# In any case, all arguments (<code>*args</code>) will be passed to Tempfile.new.
#
# Tempfile.open('foo', '/home/temp') do |f|
Expand All @@ -290,7 +297,7 @@ def open(*args, **kw)
begin
yield(tempfile)
ensure
tempfile.close!
tempfile.close
end
else
tempfile
Expand Down