refile-backgrounder 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc837f88506852f3d00d760c8f23f1a0767721e3
|
4
|
+
data.tar.gz: 59c652b614bc52718f2dac99278659a68d632244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d32a2b27377df549723f7a3749c01ea67101e42c8382086692db88cf4cdb700bcd7ba3b69b6efb26aeee83bf41f10acb4ed43970d94a1f0886ec7c2d2018267a
|
7
|
+
data.tar.gz: c8f57d6e284ba9d0110b100c33d9a55dd8382c137729671954a1543c7a7d533e47f18218aae2214a9d3550de0e6da4aecb584aab49f022808fc45359c74cb3a1
|
@@ -8,8 +8,6 @@ module Refile
|
|
8
8
|
|
9
9
|
attr_accessor :_skip_refile_backgrounder
|
10
10
|
after_save(unless: :_skip_refile_backgrounder) do |record|
|
11
|
-
metadata = record.send(name)
|
12
|
-
metadata = nil unless metadata.is_a? String
|
13
11
|
worker.perform_later record, name.to_s, metadata
|
14
12
|
end
|
15
13
|
end
|
@@ -10,15 +10,19 @@ module Refile
|
|
10
10
|
super || (background? and record.send("#{name}_cache_id"))
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def set(*)
|
14
14
|
super
|
15
|
-
|
15
|
+
save_cache_id
|
16
16
|
end
|
17
17
|
|
18
18
|
def store!
|
19
19
|
super unless background?
|
20
20
|
end
|
21
21
|
|
22
|
+
def save_cache_id
|
23
|
+
record.send "#{name}_cache_id=", cache_id if background?
|
24
|
+
end
|
25
|
+
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -4,14 +4,12 @@ module Refile
|
|
4
4
|
attr_reader :record, :attachment_name
|
5
5
|
queue_as :refile
|
6
6
|
|
7
|
-
def perform(record, attachment_name
|
7
|
+
def perform(record, attachment_name)
|
8
8
|
@record = record
|
9
9
|
@attachment_name = attachment_name
|
10
|
-
@record.send "#{attachment_name}=", metadata if metadata
|
11
10
|
return unless attachment_cached?
|
12
11
|
|
13
|
-
file = attacher.get
|
14
|
-
upload file
|
12
|
+
file = upload attacher.get
|
15
13
|
cleanup_cache!
|
16
14
|
update_record_attachment(file) if file
|
17
15
|
yield if block_given?
|
@@ -37,8 +35,8 @@ module Refile
|
|
37
35
|
|
38
36
|
def update_record_attachment(file)
|
39
37
|
record._skip_refile_backgrounder = true
|
40
|
-
record.send "#{attachment_name}_cache_id=", nil if respond_to? "#{attachment_name}_cache_id="
|
41
|
-
record.send "#{attachment_name}_id=",
|
38
|
+
record.send "#{attachment_name}_cache_id=", nil if record.respond_to? "#{attachment_name}_cache_id="
|
39
|
+
record.send "#{attachment_name}_id=", file.id if record.respond_to? "#{attachment_name}_id="
|
42
40
|
record.save
|
43
41
|
end
|
44
42
|
|