class Schoolkeep::Views::AssetCache
Attributes
host[R]
Public Class Methods
new(host)
click to toggle source
# File lib/schoolkeep/views/asset_cache.rb, line 9 def initialize(host) @host = host end
Public Instance Methods
[](path)
click to toggle source
# File lib/schoolkeep/views/asset_cache.rb, line 13 def [](path) cached_get(path) || path end
Private Instance Methods
cache()
click to toggle source
# File lib/schoolkeep/views/asset_cache.rb, line 29 def cache @cache ||= {} end
cached_get(path)
click to toggle source
# File lib/schoolkeep/views/asset_cache.rb, line 25 def cached_get(path) cache[path] ||= get(path) end
get(path)
click to toggle source
# File lib/schoolkeep/views/asset_cache.rb, line 19 def get(path) url = File.join(host, path) res = Net::HTTP.get_response(URI(url)) res["location"] end