diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/file/atomic.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/file/atomic.rb b/activesupport/lib/active_support/core_ext/file/atomic.rb index f988eff3d9..976d462e8e 100644 --- a/activesupport/lib/active_support/core_ext/file/atomic.rb +++ b/activesupport/lib/active_support/core_ext/file/atomic.rb @@ -1,5 +1,3 @@ -require 'tempfile' - module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module File #:nodoc: @@ -18,6 +16,8 @@ module ActiveSupport #:nodoc: # file.write("hello") # end def atomic_write(file_name, temp_dir = Dir.tmpdir) + require 'tempfile' unless defined?(Tempfile) + temp_file = Tempfile.new(basename(file_name), temp_dir) yield temp_file temp_file.close |