aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-23 15:31:57 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-23 15:31:57 -0800
commit308876fca262736a5fa36dddb3990b27fbc6e64a (patch)
treed52bc53563e0efcd336afd19c634257825f2ed26 /activesupport/lib
parent283418a785b5ea8b8eee56e6da181d6b91f4b155 (diff)
downloadrails-308876fca262736a5fa36dddb3990b27fbc6e64a.tar.gz
rails-308876fca262736a5fa36dddb3990b27fbc6e64a.tar.bz2
rails-308876fca262736a5fa36dddb3990b27fbc6e64a.zip
Lazy-require tempfile for File#atomic_write
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/file/atomic.rb4
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