services 5.1.2 → 6.0.0
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 +5 -5
- data/.travis.yml +3 -3
- data/lib/services/asyncable.rb +6 -26
- data/lib/services/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d1b3541d084340548b9d3779618d88edcf3c10e50ec42c92f1447aa54621a22
|
4
|
+
data.tar.gz: fb22582a1c74e144ace44144fb79272d68e0f9f73fadeea69f4ce2947f8bcc10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62bef4a68d9c9be6b9b9a345f22ee95401cb27c76aaf36a3344af308fbcbc4ba850e670961e0051127624a8e5a1f35eb7d861b695d43cba8c25c284c1bff7c1
|
7
|
+
data.tar.gz: af9097b696e781fd46c6456a37277a5e0500b70153759faf438f66813071f550a78b615f2bb90e26fc4098dd17d62d203399e96a443ac1a038951494488221ea
|
data/.travis.yml
CHANGED
data/lib/services/asyncable.rb
CHANGED
@@ -11,9 +11,6 @@ module Services
|
|
11
11
|
module Asyncable
|
12
12
|
extend ActiveSupport::Concern
|
13
13
|
|
14
|
-
# The name of the parameter that is added to the parameter list when calling a method to be processed in the background.
|
15
|
-
TARGET_PARAM_NAME = :async_target_id.freeze
|
16
|
-
|
17
14
|
ASYNC_METHOD_SUFFIXES = %i(async in at).freeze
|
18
15
|
|
19
16
|
included do
|
@@ -21,38 +18,21 @@ module Services
|
|
21
18
|
end
|
22
19
|
|
23
20
|
module ClassMethods
|
24
|
-
# Bulk enqueue items
|
25
|
-
# args can either be a one-dimensional or two-dimensional array,
|
26
|
-
# each item in args should be the arguments for one job.
|
27
|
-
def bulk_call_async(args)
|
28
|
-
# Convert args to two-dimensional array if it isn't one already.
|
29
|
-
args = args.map { |arg| [arg] } if args.none? { |arg| arg.is_a?(Array) }
|
30
|
-
Sidekiq::Client.push_bulk 'class' => self, 'args' => args
|
31
|
-
end
|
32
|
-
|
33
21
|
ASYNC_METHOD_SUFFIXES.each do |async_method_suffix|
|
34
22
|
define_method "call_#{async_method_suffix}" do |*args|
|
23
|
+
args.map! do |arg|
|
24
|
+
arg.respond_to?(:to_global_id) ? arg.to_global_id : arg
|
25
|
+
end
|
35
26
|
self.public_send "perform_#{async_method_suffix}", *args
|
36
27
|
end
|
37
28
|
end
|
38
29
|
end
|
39
30
|
|
40
|
-
ASYNC_METHOD_SUFFIXES.each do |async_method_suffix|
|
41
|
-
define_method "call_#{async_method_suffix}" do |*args|
|
42
|
-
self.class.public_send "perform_#{async_method_suffix}", *args, TARGET_PARAM_NAME => self.id
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
31
|
def perform(*args)
|
47
|
-
|
48
|
-
|
49
|
-
target = if args.last.is_a?(Hash) && args.last.keys.first.to_sym == TARGET_PARAM_NAME
|
50
|
-
self.class.find args.pop.values.first
|
51
|
-
else
|
52
|
-
self.class
|
32
|
+
args.map! do |arg|
|
33
|
+
GlobalID::Locator.locate(arg) || arg
|
53
34
|
end
|
54
|
-
|
55
|
-
target.public_send *args
|
35
|
+
call *args
|
56
36
|
end
|
57
37
|
end
|
58
38
|
end
|
data/lib/services/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.7.1
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: A nifty service layer for your Rails app
|