Class: Dragonfly::Cache::Storage::Local
- Inherits:
-
Object
- Object
- Dragonfly::Cache::Storage::Local
- Defined in:
- lib/dragonfly/cache/storage/local.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(config) ⇒ Local
constructor
A new instance of Local.
- #sha_size ⇒ Object
- #store(url, job) ⇒ Object
Constructor Details
#initialize(config) ⇒ Local
Returns a new instance of Local.
9 10 11 12 |
# File 'lib/dragonfly/cache/storage/local.rb', line 9 def initialize(config) @root = config[:server_root] @format = config[:url_format] end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/dragonfly/cache/storage/local.rb', line 7 def format @format end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/dragonfly/cache/storage/local.rb', line 7 def root @root end |
Instance Method Details
#sha_size ⇒ Object
18 19 20 21 |
# File 'lib/dragonfly/cache/storage/local.rb', line 18 def sha_size longest = Dir["#{base_dir}/*"].select { |p| File.directory?(p) }.max { |a, b| a <=> b } (longest ? File.basename(longest).size : nil) end |
#store(url, job) ⇒ Object
14 15 16 |
# File 'lib/dragonfly/cache/storage/local.rb', line 14 def store(url, job) job.to_file(path(url), mode: 0o644) end |