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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 512471669d37d29641cc7ed75639301447b024fc
4
- data.tar.gz: 95db09045fa89abd0f900f2f3b4b258d9df79353
3
+ metadata.gz: 44ddb5561ba7854b42a449e5dcc602f7a12fe15d
4
+ data.tar.gz: 802c5fd8137b31d26cc1afb3632962c2a02de4c4
5
5
  SHA512:
6
- metadata.gz: 61de9873e98b8518498566d7fcf3172022d6f91363330ae0720fa8a8df9ba8d508e5a5572ab8bfbf71f4ac5ed2bda9b31301f937be704d03cdb702f0f3852362
7
- data.tar.gz: 3484f1f2e735891ebbcdff7e95c96a3aae29bb4215c605e6a2b3577d7fe94444f4b30f0cc1ff4708d52a50ad84501667a0893bd844e63d7b99305e5c176b5efc
6
+ metadata.gz: 3c687adbd0fd0f6112ae01f1de28da66f2ea814bb7fe33471017ae900e0086476b728fb9cd1d843cf3bbbee49dcc52583f622498b530f2cb8958df39afbefde3
7
+ data.tar.gz: 7f46608f690f829b779cef2e861c9d32421b75a66f006c27b49b74dd789204e072f266ebabe078f6b5aa873b9c350ed9eebf4dfc4cae60c66230e5e5d5e3dc6f
@@ -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
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
27
- def self.#{method_name}(id, *args)
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
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
34
- def self.enqueue_#{method_name}(id, *args)
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
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
48
- def self.enqueue_#{method_name}(id, *args)
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
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Lib
3
- VERSION = "1.8.3"
3
+ VERSION = "1.8.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softwear-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie