Class: Dragonfly::Cache::Storage::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly/cache/storage/local.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#formatObject (readonly)

Returns the value of attribute format.



7
8
9
# File 'lib/dragonfly/cache/storage/local.rb', line 7

def format
  @format
end

#rootObject (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_sizeObject



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