aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2010-11-15 21:51:10 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-16 00:04:37 +0100
commit2bed4d94e65f81c07a6e7844936d62be71f6eb24 (patch)
treece9722c18fcd8f08f2ee8bc55321b0ef43412e74 /actionpack
parentce1f87673c17338617222a4e4e0971cfb9f0655f (diff)
downloadrails-2bed4d94e65f81c07a6e7844936d62be71f6eb24.tar.gz
rails-2bed4d94e65f81c07a6e7844936d62be71f6eb24.tar.bz2
rails-2bed4d94e65f81c07a6e7844936d62be71f6eb24.zip
changed asset_timestamps_cache to asset_ids_cache, added an rdoc comment to the new public api, and updated the railtie
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb34
-rw-r--r--actionpack/lib/action_view/railtie.rb4
2 files changed, 21 insertions, 17 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
index 7a00c8e69d..b4e61f2034 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -5,13 +5,14 @@ module ActionView
module AssetTagHelper
class AssetPaths
- # You can enable or disable the asset tag timestamps cache.
+ # You can enable or disable the asset tag ids cache.
# With the cache enabled, the asset tag helper methods will make fewer
- # expensive file system calls. However this prevents you from modifying
- # any asset files while the server is running.
+ # expensive file system calls (the default implementation checks the file
+ # system timestamp). However this prevents you from modifying any asset
+ # files while the server is running.
#
- # ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
- mattr_accessor :cache_asset_timestamps
+ # ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids = false
+ mattr_accessor :cache_asset_ids
attr_reader :config, :controller
@@ -41,9 +42,12 @@ module ActionView
source
end
- def add_to_asset_timestamp_cache(source, asset_id)
- self.asset_timestamps_cache_guard.synchronize do
- self.asset_timestamps_cache[source] = asset_id
+ # Add or change an asset id in the asset id cache. This can be used
+ # for SASS on Heroku.
+ # :api: public
+ def add_to_asset_ids_cache(source, asset_id)
+ self.asset_ids_cache_guard.synchronize do
+ self.asset_ids_cache[source] = asset_id
end
end
@@ -83,11 +87,11 @@ module ActionView
end
end
- mattr_accessor :asset_timestamps_cache
- self.asset_timestamps_cache = {}
+ mattr_accessor :asset_ids_cache
+ self.asset_ids_cache = {}
- mattr_accessor :asset_timestamps_cache_guard
- self.asset_timestamps_cache_guard = Mutex.new
+ mattr_accessor :asset_ids_cache_guard
+ self.asset_ids_cache_guard = Mutex.new
# Use the RAILS_ASSET_ID environment variable or the source's
# modification time as its cache-busting asset id.
@@ -95,14 +99,14 @@ module ActionView
if asset_id = ENV["RAILS_ASSET_ID"]
asset_id
else
- if self.cache_asset_timestamps && (asset_id = self.asset_timestamps_cache[source])
+ if self.cache_asset_ids && (asset_id = self.asset_ids_cache[source])
asset_id
else
path = File.join(config.assets_dir, source)
asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
- if self.cache_asset_timestamps
- add_to_asset_timestamp_cache(source, asset_id)
+ if self.cache_asset_ids
+ add_to_asset_ids_cache(source, asset_id)
end
asset_id
diff --git a/actionpack/lib/action_view/railtie.rb b/actionpack/lib/action_view/railtie.rb
index bed95aa7f7..71cd1a788a 100644
--- a/actionpack/lib/action_view/railtie.rb
+++ b/actionpack/lib/action_view/railtie.rb
@@ -8,10 +8,10 @@ module ActionView
config.action_view.stylesheet_expansions = {}
config.action_view.javascript_expansions = { :defaults => ['prototype', 'effects', 'dragdrop', 'controls', 'rails'] }
- initializer "action_view.cache_asset_timestamps" do |app|
+ initializer "action_view.cache_asset_ids" do |app|
unless app.config.cache_classes
ActiveSupport.on_load(:action_view) do
- ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_timestamps = false
+ ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids = false
end
end
end