eitil 0.3.5 → 0.3.6
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92cb9e9c82e5a3bfac7cbc0b5f662428bac557a2c3abbca8e30c86d60174363a
|
4
|
+
data.tar.gz: 20c072c5d8b8ce2e055ff0635472a66fdb11ba4155d770ac3cd600be0c0892da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945e8da34ffe7c89a24c11d2c4f75f2861ed9355ed0ed0c6759cc57d63485d7bb37006be1c4cb4f1fa8c93d13a672b238f4c99ec3110001db917cdc4cc2e02e0
|
7
|
+
data.tar.gz: d0a0641152e75e6f100eda08f83a3b253d8d80dd570fb26d76a2649822180e0f3c834da64012bb5d0e61709163fc81dbc7986ec5fa04d8d74faa8fd6a7f290a9
|
data/README.md
CHANGED
@@ -227,14 +227,18 @@ The router wrapper is a single module which is automatically included into your
|
|
227
227
|
|
228
228
|
### Info
|
229
229
|
|
230
|
-
The Eitil jobs wrapper enables you to create perform_later jobs on the fly, without the need to create a new class and file. The macro new_job accepts a :method as argument and defines a new method :method_job. The newly defined :method_job, when called, performs the orginal :method in the background. The new_job macro accepts both instance methods and singleton methods, which are defined within there own method scope.
|
230
|
+
The Eitil jobs wrapper enables you to create perform_now and perform_later jobs on the fly, without the need to create a new class and file. The macro new_job accepts a :method as argument and defines a new method :method_job. The newly defined :method_job, when called, performs the orginal :method in the background. The new_job macro accepts both instance methods and singleton methods, which are defined within there own method scope. In contrast, the new_job_debugger macro defines a new :method_job_debugger method, which performs in the foreground.
|
231
231
|
|
232
232
|
### Job Macro
|
233
233
|
|
234
234
|
```ruby
|
235
|
-
new_job(_method)
|
236
|
-
# assuming a method :
|
237
|
-
# =>
|
235
|
+
new_job(_method, *args, **kwargs)
|
236
|
+
# assuming a method :hello_world, call as: new_job :hello_world
|
237
|
+
# => defines :hello_world_job
|
238
|
+
|
239
|
+
new_job_debugger(_method, *args, **kwargs)
|
240
|
+
# assuming a method :hello_world, call as: new_job_debugger :hello_world
|
241
|
+
# => defines :hello_world_job_debugger
|
238
242
|
```
|
239
243
|
|
240
244
|
- method is
|
@@ -6,19 +6,47 @@ Kernel.module_eval do
|
|
6
6
|
# being that 'id' works for objects that have a database record, while '_self'
|
7
7
|
# works for non database supported instanes, such as an Exporter instance.
|
8
8
|
|
9
|
-
def new_job(_method)
|
9
|
+
def new_job(_method, *args, **kwargs)
|
10
10
|
|
11
11
|
if instance_methods(false).include? _method
|
12
|
-
define_method "#{_method}_job" do |_self = nil|
|
13
|
-
|
12
|
+
define_method "#{_method}_job" do |_self = nil, *args, **kwargs|
|
13
|
+
|
14
|
+
Eitil::SingleMethodJob.perform_later(
|
15
|
+
*args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
|
16
|
+
)
|
14
17
|
end
|
15
18
|
|
16
|
-
elsif singleton_methods(false).include? _method
|
17
|
-
define_singleton_method "#{_method}_job" do
|
18
|
-
|
19
|
+
elsif singleton_methods(false).include? _method
|
20
|
+
define_singleton_method "#{_method}_job" do |*args, **kwargs|
|
21
|
+
|
22
|
+
Eitil::SingleMethodJob.perform_later(
|
23
|
+
*args, _class: to_s, _method: _method.to_s, **kwargs
|
24
|
+
)
|
19
25
|
end
|
20
|
-
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# BEWARE: This is an exact copy of the above method, except for .perform_now instead of .perform_later and the method's name.
|
30
|
+
# The reason for not using helper methods is to not unnecessarily fill and potentially fuck up the Kernel environment.
|
21
31
|
|
32
|
+
def new_job_debugger(_method, *args, **kwargs)
|
33
|
+
|
34
|
+
if instance_methods(false).include? _method
|
35
|
+
define_method "#{_method}_job_debugger" do |_self = nil, *args, **kwargs|
|
36
|
+
|
37
|
+
Eitil::SingleMethodJob.perform_now(
|
38
|
+
*args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
elsif singleton_methods(false).include? _method
|
43
|
+
define_singleton_method "#{_method}_job_debugger" do |*args, **kwargs|
|
44
|
+
|
45
|
+
Eitil::SingleMethodJob.perform_now(
|
46
|
+
*args, _class: to_s, _method: _method.to_s, **kwargs
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
22
50
|
end
|
23
51
|
|
24
52
|
end
|
@@ -8,9 +8,7 @@ module Eitil
|
|
8
8
|
# being that 'id' works for objects that have a database record, while '_self'
|
9
9
|
# works for non database supported instanes, such as an Exporter instance.
|
10
10
|
|
11
|
-
def perform(_class:, _method:, id: nil, _self: nil)
|
12
|
-
binding.pry
|
13
|
-
|
11
|
+
def perform(*args, _class:, _method:, id: nil, _self: nil, **kwargs)
|
14
12
|
object =
|
15
13
|
if id
|
16
14
|
_class.constantize.find(id)
|
@@ -20,7 +18,7 @@ module Eitil
|
|
20
18
|
_class.constantize
|
21
19
|
end
|
22
20
|
|
23
|
-
object.send _method
|
21
|
+
object.send _method, *args, **kwargs
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
data/lib/eitil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eitil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Schrofer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|