Class: Ratonvirus::Storage::Carrierwave
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #process
Instance Method Details
#accept?(resource) ⇒ Boolean
12
13
14
15
16
17
18
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 12
def accept?(resource)
if resource.is_a?(Array)
resource.all? { |subr| subr.is_a?(::CarrierWave::Uploader::Base) }
else
resource.is_a?(::CarrierWave::Uploader::Base)
end
end
|
#asset_path(asset, &block) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 20
def asset_path(asset, &block)
return unless block_given?
return if asset.nil?
return if asset.file.nil?
return yield asset.file.path if asset.file.is_a?(::CarrierWave::SanitizedFile)
io = StringIO.new(asset.file.read)
ext = File.extname(asset.file.path)
io_path(io, ext, &block)
end
|
#asset_remove(asset) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 38
def asset_remove(asset)
path = asset.file.path
delete_dir = asset.file.is_a?(::CarrierWave::SanitizedFile)
asset.remove!
return unless delete_dir
dir = File.dirname(path)
FileUtils.remove_dir(dir) if File.directory?(dir)
end
|
#changed?(record, attribute) ⇒ Boolean
8
9
10
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 8
def changed?(record, attribute)
record.public_send :"#{attribute}_changed?"
end
|