Allows you to set ActionController::Base.asset_host as a proc.
This allows you to get by the hardcoded assumption that you can setup 4 hosts numbered from 0-3 and also to do possibly smarter things depending on the asset path. E.g this allows you to randomly get assets from 2 hosts (assets1.example.com and assets2.example.com).
ActionController::Base.asset_host = Proc.new { |source| "http://assets#{rand(2) + 1}.example.com" }
Another example where you can use the source param that's passed to the block to decide where to get the asset from (useful if you have, say, images hosted elsewhere, or you want an SEO-friendly URL for your images):
ActionController::Base.asset_host = Proc.new { |source|
if source.starts_with?('/images')
"http://images.example.com"
else
"http://assets.example.com"
end
}
It may sound like it could be expensive with a complicated proc, but this asset and path computation happens only the first time and is cached afterwards like all other computed paths.
Docs and tests in the patch.