Class: Ratonvirus::Storage::ActiveStorage
- Inherits:
-
Base
- Object
- Base
- Ratonvirus::Storage::ActiveStorage
show all
- Defined in:
- lib/ratonvirus/storage/active_storage.rb
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#accept?(resource) ⇒ Boolean
23
24
25
26
|
# File 'lib/ratonvirus/storage/active_storage.rb', line 23
def accept?(resource)
resource.is_a?(::ActiveStorage::Attached::One) ||
resource.is_a?(::ActiveStorage::Attached::Many)
end
|
#asset_path(asset, &block) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/ratonvirus/storage/active_storage.rb', line 43
def asset_path(asset, &block)
return unless block_given?
return if asset.nil?
return unless asset.blob
blob_path asset.blob, &block
end
|
#asset_remove(asset) ⇒ Object
51
52
53
|
# File 'lib/ratonvirus/storage/active_storage.rb', line 51
def asset_remove(asset)
asset.purge
end
|
#changed?(_record, _attribute) ⇒ Boolean
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ratonvirus/storage/active_storage.rb', line 6
def changed?(_record, _attribute)
true
end
|
#process(resource, &_block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/ratonvirus/storage/active_storage.rb', line 28
def process(resource, &_block)
return unless block_given?
return if resource.nil?
return unless resource.attached?
if resource.is_a?(::ActiveStorage::Attached::One)
yield processable(resource.attachment) if resource.attachment
elsif resource.is_a?(::ActiveStorage::Attached::Many)
resource.attachments.each do |attachment|
yield processable(attachment)
end
end
end
|