Class: SocialAvatarProxy::Configuration::FileCache
- Inherits:
-
Cache
- Object
- Cache
- SocialAvatarProxy::Configuration::FileCache
show all
- Defined in:
- lib/social_avatar_proxy/configuration/file_cache.rb
Instance Method Summary
collapse
Methods inherited from Cache
#configure, #disabled?, #enabled?, #fetch
Instance Method Details
#read(options = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/social_avatar_proxy/configuration/file_cache.rb', line 9
def read(options = {})
path = generate_key(options)
unless File.exist?(path) && File.readable?(path)
return false
end
AvatarFile.new(path).tap do |file|
file.mtime(File.mtime(path))
end
end
|
#write(file, options = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/social_avatar_proxy/configuration/file_cache.rb', line 21
def write(file, options = {})
path = generate_key(options)
FileUtils.mkdir_p File.dirname(path)
File.open(path, "wb") do |f|
f.write(file.read)
end
end
|