Class: Ratonvirus::Storage::Filepath
- Inherits:
-
Base
- Object
- Base
- Ratonvirus::Storage::Filepath
show all
- Defined in:
- lib/ratonvirus/storage/filepath.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
15
16
17
18
19
20
21
|
# File 'lib/ratonvirus/storage/filepath.rb', line 15
def accept?(resource)
if resource.is_a?(Array)
resource.all? { |r| r.is_a?(String) || r.is_a?(File) }
else
resource.is_a?(String) || resource.is_a?(File)
end
end
|
#asset_path(asset) {|asset| ... } ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ratonvirus/storage/filepath.rb', line 23
def asset_path(asset, &block)
return unless block_given?
return unless asset
return if asset.empty?
if asset.respond_to?(:path)
asset_path(asset.path, &block)
return
end
yield asset
end
|
#asset_remove(asset) ⇒ Object
41
42
43
|
# File 'lib/ratonvirus/storage/filepath.rb', line 41
def asset_remove(asset)
FileUtils.remove_file(asset) if File.file?(asset)
end
|
#changed?(record, attribute) ⇒ Boolean
6
7
8
9
10
11
12
13
|
# File 'lib/ratonvirus/storage/filepath.rb', line 6
def changed?(record, attribute)
return record.public_send :"#{attribute}_changed?" if record.respond_to? :"#{attribute}_changed?"
record.changed?
end
|