Class: Dragonfly::Cache::Plugin

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

Overview

:nodoc:

Constant Summary collapse

@@servers =

rubocop:disable Style/ClassVars

{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

rubocop:enable Style/ClassVars



20
21
22
# File 'lib/dragonfly/cache/plugin.rb', line 20

def config
  @config
end

#managerObject (readonly)

rubocop:enable Style/ClassVars



20
21
22
# File 'lib/dragonfly/cache/plugin.rb', line 20

def manager
  @manager
end

Instance Method Details

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



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dragonfly/cache/plugin.rb', line 24

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



36
37
38
# File 'lib/dragonfly/cache/plugin.rb', line 36

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