aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorIan Ker-Seymer <i.kerseymer@gmail.com>2015-01-28 00:33:57 -0700
committerIan Ker-Seymer <i.kerseymer@gmail.com>2015-01-28 00:40:25 -0700
commitb3c23f117695b3089c03b7c0d78781c176b2c418 (patch)
tree8e22ceeb85b8099b84a4f3efe3fda92875bb0766 /activesupport/lib
parent36082a62048248c27cdd513c943ee94b716bd7f8 (diff)
downloadrails-b3c23f117695b3089c03b7c0d78781c176b2c418.tar.gz
rails-b3c23f117695b3089c03b7c0d78781c176b2c418.tar.bz2
rails-b3c23f117695b3089c03b7c0d78781c176b2c418.zip
Return value of yielded block in File.atomic_write
Staying true to Ruby convention, we now return the value of the yielded block from `File.atomic_write {...}`. This mimics the behavior of MRI's `File.open {...}`.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/file/atomic.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/file/atomic.rb b/activesupport/lib/active_support/core_ext/file/atomic.rb
index 38374af388..fad6fa8d9d 100644
--- a/activesupport/lib/active_support/core_ext/file/atomic.rb
+++ b/activesupport/lib/active_support/core_ext/file/atomic.rb
@@ -20,7 +20,7 @@ class File
temp_file = Tempfile.new(basename(file_name), temp_dir)
temp_file.binmode
- yield temp_file
+ return_val = yield temp_file
temp_file.close
if File.exist?(file_name)
@@ -40,6 +40,9 @@ class File
chown(old_stat.uid, old_stat.gid, file_name)
# This operation will affect filesystem ACL's
chmod(old_stat.mode, file_name)
+
+ # Make sure we return the result of the yielded block
+ return_val
rescue Errno::EPERM, Errno::EACCES
# Changing file ownership failed, moving on.
end