aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-11-27 17:51:33 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-27 17:51:33 +0100
commit229f959d15e451890db60dbb73f8565079977814 (patch)
treec2ca2865b84f5895458dd71c557a75f07be3d68b /actionpack/lib
parent3cc9d1c5ad1639283b43ee2b6099cb4f3b19bf23 (diff)
downloadrails-229f959d15e451890db60dbb73f8565079977814.tar.gz
rails-229f959d15e451890db60dbb73f8565079977814.tar.bz2
rails-229f959d15e451890db60dbb73f8565079977814.zip
Added the option to declare an asset_host as an object that responds to call (see http://github.com/dhh/asset-hosting-with-minimum-ssl for an example) [DHH]
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 4352d7819b..134907311a 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -80,6 +80,12 @@ module ActionView
# end
# }
#
+ # You can also implement a custom asset host object that responds to the call method and tasks one or two parameters just like the proc.
+ #
+ # config.action_controller.asset_host = AssetHostingWithMinimumSsl.new(
+ # "http://asset%d.example.com", "https://asset1.example.com"
+ # )
+ #
# === Using asset timestamps
#
# By default, Rails will append all asset paths with that asset's timestamp. This allows you to set a cache-expiration date for the
@@ -359,6 +365,7 @@ module ActionView
# compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching
# is set to true (which is the case by default for the Rails production environment, but not for the development
# environment). Examples:
+
#
# ==== Examples
# stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is false =>
@@ -629,11 +636,12 @@ module ActionView
# Pick an asset host for this source. Returns +nil+ if no host is set,
# the host if no wildcard is set, the host interpolated with the
# numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
- # or the value returned from invoking the proc if it's a proc.
+ # or the value returned from invoking the proc if it's a proc or the value from
+ # invoking call if it's an object responding to call.
def compute_asset_host(source)
if host = ActionController::Base.asset_host
- if host.is_a?(Proc)
- case host.arity
+ if host.is_a?(Proc) || host.respond_to?(:call)
+ case host.is_a?(Proc) ? host.arity : host.method(:call).arity
when 2
host.call(source, request)
else