class Dragonfly::Cache::Plugin
Attributes
config[R]
manager[R]
Public Instance Methods
call(app, cache_servers_options = {})
click to toggle source
# File lib/dragonfly/cache/plugin.rb, line 22 def call(app, cache_servers_options = {}) @config = Dragonfly::Cache::Config.new(cache_servers_options) @manager = Dragonfly::Cache::Manager.new(self) app.define_url do |same, job, opts| url_for(same, job, opts) rescue Dragonfly::Cache::Error => e Dragonfly.warn(e.message) app.server.url_for(job, opts) # Fallback to default Dragonfly::App url building end end
url_for(app, job, opts)
click to toggle source
# File lib/dragonfly/cache/plugin.rb, line 34 def url_for(app, job, opts) cache(job) { build_url_for(app, job, opts) } end
Protected Instance Methods
build_url_for(app, job, opts)
click to toggle source
# File lib/dragonfly/cache/plugin.rb, line 40 def build_url_for(app, job, opts) loop do url = server_for(app).url_for(job, job_options(job).merge(opts)) path = URI.parse(url).path return path if valid?(job, path) end end
server_for(app)
click to toggle source
# File lib/dragonfly/cache/plugin.rb, line 48 def server_for(app) @@servers[app.name] ||= begin server = app.server.dup config.servers_options.each do |name, value| server.send("#{name}=", value) if server.respond_to?("#{name}=") end server end end