delayed_after_commit 0.1.3 → 0.1.4
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/version.rb +1 -1
- data/lib/delayed_after_commit.rb +11 -7
- 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: 687299ca082fb4e9f214519ae1220db104880877
|
4
|
+
data.tar.gz: e1b04ed34dcc255948620b00b646385ae1bf2de2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4796260a88f2bfee9a0a6814f8cb82ecc42bd36aaee0df1b5de1bbe1e26fa02fadf2a11d08cfe661c933d405329ce19df66913f8e767cd2229651526e24a1587
|
7
|
+
data.tar.gz: c48126fdfd2615356965c8dbb03ebe296f022bb437400e1949e48956a4a40773bf0f314e7e46b3fa9cebf744d0be6a7e2ebbd4155fc4d5003ac7962e898182a4
|
data/lib/delayed_after_commit.rb
CHANGED
@@ -11,23 +11,27 @@ module DelayedAfterCommit
|
|
11
11
|
obj.send(method)
|
12
12
|
end
|
13
13
|
|
14
|
-
def delayed_after_create(
|
15
|
-
|
14
|
+
def delayed_after_create(*args, &block)
|
15
|
+
args << {on: :create}
|
16
|
+
delayed_after_commit(*args, &block)
|
16
17
|
end
|
17
18
|
|
18
|
-
def delayed_after_update(
|
19
|
-
|
19
|
+
def delayed_after_update(*args, &block)
|
20
|
+
args << {on: :update}
|
21
|
+
delayed_after_commit(*args, &block)
|
20
22
|
end
|
21
23
|
|
22
24
|
protected
|
23
|
-
def delayed_after_commit(
|
25
|
+
def delayed_after_commit(*args, &block)
|
24
26
|
# this creates a method that runs `enqueue_delayed_method`
|
25
27
|
# it then adds that method to the after_commit callback
|
26
|
-
|
28
|
+
opts = args.extract_options!
|
29
|
+
method = args.first
|
30
|
+
delayed_method_name = "delayed_after_#{opts[:on]}_#{method}"
|
27
31
|
define_method(delayed_method_name) do |m = method|
|
28
32
|
self.class.delay.enqueue_delayed_method(m, self.id)
|
29
33
|
end
|
30
|
-
self.after_commit(delayed_method_name.to_sym,
|
34
|
+
self.after_commit(delayed_method_name.to_sym, opts, &block)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|