Class: Ratonvirus::Storage::Carrierwave
- Inherits:
-
Base
- Object
- Base
- Ratonvirus::Storage::Carrierwave
show all
- Defined in:
- lib/ratonvirus/storage/carrierwave.rb
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #process
Instance Method Details
#accept?(resource) ⇒ Boolean
10
11
12
13
14
15
16
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 10
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) {|asset.file.path| ... } ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 18
def asset_path(asset)
return unless block_given?
return if asset.nil?
return if asset.file.nil?
yield asset.file.path
end
|
#asset_remove(asset) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 26
def asset_remove(asset)
path = asset.file.path
asset.remove!
dir = File.dirname(path)
FileUtils.remove_dir(dir) if File.directory?(dir)
end
|
#changed?(record, attribute) ⇒ Boolean
6
7
8
|
# File 'lib/ratonvirus/storage/carrierwave.rb', line 6
def changed?(record, attribute)
record.public_send :"#{attribute}_changed?"
end
|