diff options
Diffstat (limited to 'railties/lib/rails/dev_caching.rb')
-rw-r--r-- | railties/lib/rails/dev_caching.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/railties/lib/rails/dev_caching.rb b/railties/lib/rails/dev_caching.rb new file mode 100644 index 0000000000..f69275a34a --- /dev/null +++ b/railties/lib/rails/dev_caching.rb @@ -0,0 +1,43 @@ +require "fileutils" + +module Rails + module DevCaching # :nodoc: + class << self + FILE = "tmp/caching-dev.txt" + + def enable_by_file + FileUtils.mkdir_p("tmp") + + if File.exist?(FILE) + delete_cache_file + puts "Development mode is no longer being cached." + else + create_cache_file + puts "Development mode is now being cached." + end + + FileUtils.touch "tmp/restart.txt" + FileUtils.rm_f("tmp/pids/server.pid") + end + + def enable_by_argument(caching) + FileUtils.mkdir_p("tmp") + + if caching + create_cache_file + elsif caching == false && File.exist?(FILE) + delete_cache_file + end + end + + private + def create_cache_file + FileUtils.touch FILE + end + + def delete_cache_file + File.delete FILE + end + end + end +end |