delayed_after_commit 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed_after_commit.rb +6 -6
- data/lib/delayed_after_commit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5c2eaced3dc09bcd1478656122d4b108ed0f2e
|
4
|
+
data.tar.gz: ceb37a45202f51e11b36ded5eb7e193ca9951acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fa32073e9e9127762c3e4a5242b8f1152a76a1392696182b45e104adf7690716fd173dade874fcded27a93431cfcbf5cd8289767f7139d61a6dba9453a68c5
|
7
|
+
data.tar.gz: 2eab58dd585a70865cd61732845c740108f3552f58597826c5499172e5f379ff00370eec164b5bc3f359bc967c508722bb54d80067b0ccce69fb117c78d3d5ea
|
data/lib/delayed_after_commit.rb
CHANGED
@@ -11,23 +11,23 @@ module DelayedAfterCommit
|
|
11
11
|
obj.send(method)
|
12
12
|
end
|
13
13
|
|
14
|
-
def delayed_on_create(method)
|
15
|
-
delayed_after_commit(method, on: :create)
|
14
|
+
def delayed_on_create(method, &block)
|
15
|
+
delayed_after_commit(method, on: :create, &block)
|
16
16
|
end
|
17
17
|
|
18
|
-
def delayed_on_update(method)
|
19
|
-
delayed_after_commit(method, on: :update)
|
18
|
+
def delayed_on_update(method, &block)
|
19
|
+
delayed_after_commit(method, on: :update, &block)
|
20
20
|
end
|
21
21
|
|
22
22
|
protected
|
23
|
-
def delayed_after_commit(method, on
|
23
|
+
def delayed_after_commit(method, on:, &block)
|
24
24
|
# this creates a method that runs `enqueue_delayed_method`
|
25
25
|
# it then adds that method to the after_commit callback
|
26
26
|
delayed_method_name = "delayed_after_#{on}_#{method}"
|
27
27
|
define_method(delayed_method_name) do |m = method|
|
28
28
|
self.class.delay.enqueue_delayed_method(m, self.id)
|
29
29
|
end
|
30
|
-
self.after_commit(delayed_method_name.to_sym, on: on)
|
30
|
+
self.after_commit(delayed_method_name.to_sym, on: on, &block)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|