softwear-lib 1.8.3 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/softwear/lib/enqueue.rb +21 -7
- data/lib/softwear/lib/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: 44ddb5561ba7854b42a449e5dcc602f7a12fe15d
|
4
|
+
data.tar.gz: 802c5fd8137b31d26cc1afb3632962c2a02de4c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c687adbd0fd0f6112ae01f1de28da66f2ea814bb7fe33471017ae900e0086476b728fb9cd1d843cf3bbbee49dcc52583f622498b530f2cb8958df39afbefde3
|
7
|
+
data.tar.gz: 7f46608f690f829b779cef2e861c9d32421b75a66f006c27b49b74dd789204e072f266ebabe078f6b5aa873b9c350ed9eebf4dfc4cae60c66230e5e5d5e3dc6f
|
data/lib/softwear/lib/enqueue.rb
CHANGED
@@ -22,33 +22,44 @@ module Softwear
|
|
22
22
|
end
|
23
23
|
raise "enqueue what?" if method_names.empty?
|
24
24
|
|
25
|
+
# We will extend the class mod and include the instance mod.
|
26
|
+
# This allows us to override the generated enqueue methods and
|
27
|
+
# call `super`.
|
28
|
+
#
|
29
|
+
enqueue_class_mod = Module.new
|
30
|
+
enqueue_instance_mod = Module.new
|
31
|
+
|
25
32
|
method_names.each do |method_name|
|
26
|
-
|
27
|
-
def
|
33
|
+
enqueue_class_mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
34
|
+
def #{method_name}(id, *args)
|
28
35
|
find(id).#{method_name}(*args)
|
29
36
|
end
|
30
37
|
RUBY
|
31
38
|
|
32
39
|
if Rails.env.production?
|
33
|
-
|
34
|
-
def
|
40
|
+
enqueue_class_mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
41
|
+
def enqueue_#{method_name}(id, *args)
|
35
42
|
::Sidekiq::Client.push(
|
36
43
|
'class' => ::Softwear::Lib::Enqueue::Worker,
|
37
44
|
'args' => [name, id, #{method_name.inspect}] + args,
|
38
45
|
'queue' => #{options[:queue].inspect}
|
39
46
|
)
|
40
47
|
end
|
48
|
+
RUBY
|
41
49
|
|
50
|
+
enqueue_instance_mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
42
51
|
def enqueue_#{method_name}(*args)
|
43
|
-
self.class.enqueue_#{method_name}(*args)
|
52
|
+
self.class.enqueue_#{method_name}(id, *args)
|
44
53
|
end
|
45
54
|
RUBY
|
46
55
|
else
|
47
|
-
|
48
|
-
def
|
56
|
+
enqueue_class_mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
57
|
+
def enqueue_#{method_name}(id, *args)
|
49
58
|
self.#{method_name}(id, *args)
|
50
59
|
end
|
60
|
+
RUBY
|
51
61
|
|
62
|
+
enqueue_instance_mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
52
63
|
def enqueue_#{method_name}(*args)
|
53
64
|
self.#{method_name}(*args)
|
54
65
|
end
|
@@ -56,6 +67,9 @@ module Softwear
|
|
56
67
|
end
|
57
68
|
end
|
58
69
|
|
70
|
+
send :extend, enqueue_class_mod
|
71
|
+
send :include, enqueue_instance_mod
|
72
|
+
|
59
73
|
r = method_names.map { |m| "enqueue_#{m}".to_sym }
|
60
74
|
r.size == 1 ? r.first : r
|
61
75
|
end
|
data/lib/softwear/lib/version.rb
CHANGED