Created
April 29, 2009 23:21
-
-
Save marshmallowcreme/104132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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. | |
| def compute_asset_host(source) | |
| if host = ActionController::Base.asset_host | |
| if host.is_a?(Proc) | |
| case host.arity | |
| when 2 | |
| host.call(source, @controller.request) | |
| else | |
| host.call(source) | |
| end | |
| else | |
| (host =~ /%d/) ? host % (source.hash % 4) : host | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment