Skip to content
This repository
Browse code

changed asset_timestamps_cache to asset_ids_cache, added an rdoc comm…

…ent to the new public api, and updated the railtie
  • Loading branch information...
commit 2bed4d94e65f81c07a6e7844936d62be71f6eb24 1 parent ce1f876
Josh Kalderimis authored November 15, 2010 josevalim committed November 16, 2010
34  actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -5,13 +5,14 @@ module Helpers
5 5
     module AssetTagHelper
6 6
 
7 7
       class AssetPaths
8  
-        # You can enable or disable the asset tag timestamps cache.
  8
+        # You can enable or disable the asset tag ids cache.
9 9
         # With the cache enabled, the asset tag helper methods will make fewer
10  
-        # expensive file system calls. However this prevents you from modifying
11  
-        # any asset files while the server is running.
  10
+        # expensive file system calls (the default implementation checks the file
  11
+        # system timestamp). However this prevents you from modifying any asset
  12
+        # files while the server is running.
12 13
         #
13  
-        #   ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
14  
-        mattr_accessor :cache_asset_timestamps
  14
+        #   ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids = false
  15
+        mattr_accessor :cache_asset_ids
15 16
 
16 17
         attr_reader :config, :controller
17 18
 
@@ -41,9 +42,12 @@ def compute_public_path(source, dir, ext = nil, include_host = true)
41 42
           source
42 43
         end
43 44
 
44  
-        def add_to_asset_timestamp_cache(source, asset_id)
45  
-          self.asset_timestamps_cache_guard.synchronize do
46  
-            self.asset_timestamps_cache[source] = asset_id
  45
+        # Add or change an asset id in the asset id cache. This can be used
  46
+        # for SASS on Heroku.
  47
+        # :api: public
  48
+        def add_to_asset_ids_cache(source, asset_id)
  49
+          self.asset_ids_cache_guard.synchronize do
  50
+            self.asset_ids_cache[source] = asset_id
47 51
           end
48 52
         end
49 53
 
@@ -83,11 +87,11 @@ def rewrite_asset_path(source, path = nil)
83 87
             end
84 88
           end
85 89
 
86  
-          mattr_accessor :asset_timestamps_cache
87  
-          self.asset_timestamps_cache = {}
  90
+          mattr_accessor :asset_ids_cache
  91
+          self.asset_ids_cache = {}
88 92
 
89  
-          mattr_accessor :asset_timestamps_cache_guard
90  
-          self.asset_timestamps_cache_guard = Mutex.new
  93
+          mattr_accessor :asset_ids_cache_guard
  94
+          self.asset_ids_cache_guard = Mutex.new
91 95
 
92 96
           # Use the RAILS_ASSET_ID environment variable or the source's
93 97
           # modification time as its cache-busting asset id.
@@ -95,14 +99,14 @@ def rails_asset_id(source)
95 99
             if asset_id = ENV["RAILS_ASSET_ID"]
96 100
               asset_id
97 101
             else
98  
-              if self.cache_asset_timestamps && (asset_id = self.asset_timestamps_cache[source])
  102
+              if self.cache_asset_ids && (asset_id = self.asset_ids_cache[source])
99 103
                 asset_id
100 104
               else
101 105
                 path = File.join(config.assets_dir, source)
102 106
                 asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
103 107
 
104  
-                if self.cache_asset_timestamps
105  
-                  add_to_asset_timestamp_cache(source, asset_id)
  108
+                if self.cache_asset_ids
  109
+                  add_to_asset_ids_cache(source, asset_id)
106 110
                 end
107 111
 
108 112
                 asset_id
4  actionpack/lib/action_view/railtie.rb
@@ -8,10 +8,10 @@ class Railtie < Rails::Railtie
8 8
     config.action_view.stylesheet_expansions = {}
9 9
     config.action_view.javascript_expansions = { :defaults => ['prototype', 'effects', 'dragdrop', 'controls', 'rails'] }
10 10
 
11  
-    initializer "action_view.cache_asset_timestamps" do |app|
  11
+    initializer "action_view.cache_asset_ids" do |app|
12 12
       unless app.config.cache_classes
13 13
         ActiveSupport.on_load(:action_view) do
14  
-          ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_timestamps = false
  14
+          ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids = false
15 15
         end
16 16
       end
17 17
     end

0 notes on commit 2bed4d9

Please sign in to comment.
Something went wrong with that request. Please try again.