Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #action_view/helpers/asset_tag_helper.rb
  2. class AssetTag
  3.  
  4. # NOTE: This 'Cache' stays around forever
  5. Cache = {}
  6. CacheGuard = Mutex.new
  7.  
  8. def self.create(template, controller, source, include_host = true)
  9. CacheGuard.synchronize do
  10. key = if controller.respond_to?(:request)
  11. [self, controller.request.protocol,
  12. ActionController::Base.asset_host,
  13. ActionController::Base.relative_url_root,
  14. source, include_host]
  15. else
  16. [self, ActionController::Base.asset_host, source, include_host]
  17. end
  18.  
  19. # NOTE Put EVERY asset tag (css,js, and all images) into a static cache
  20. Cache[key] ||= new(template, controller, source, include_host).freeze
  21. end
  22. end
Add Comment
Please, Sign In to add comment