Class: Dragonfly::Cache::Plugin

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dragonfly/cache/plugin.rb

Constant Summary collapse

@@servers =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



18
19
20
# File 'lib/dragonfly/cache/plugin.rb', line 18

def config
  @config
end

#managerObject (readonly)

Returns the value of attribute manager.



18
19
20
# File 'lib/dragonfly/cache/plugin.rb', line 18

def manager
  @manager
end

Instance Method Details

#call(app, cache_servers_options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# 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) ⇒ Object



34
35
36
# File 'lib/dragonfly/cache/plugin.rb', line 34

def url_for(app, job, opts)
  cache(job) { build_url_for(app, job, opts) }
end