Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@joshk joshk authored josevalim committed
View
34 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -5,13 +5,14 @@ module Helpers
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 @@ def compute_public_path(source, dir, ext = nil, include_host = true)
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 @@ def rewrite_asset_path(source, path = nil)
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 @@ def rails_asset_id(source)
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
View
4 actionpack/lib/action_view/railtie.rb
@@ -8,10 +8,10 @@ class Railtie < Rails::Railtie
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
Please sign in to comment.
Something went wrong with that request. Please try again.