services 7.3.3 → 8.0.0

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
  SHA256:
3
- metadata.gz: 510d4c3f8f8663e0079e9a9cea599cbf4d6173b674531b3c562e86596b510cb8
4
- data.tar.gz: b4c3da22b80c5336cb5d1db80f89519847e0057c25a6a9875fe4b4c5693eda05
3
+ metadata.gz: 968f73b837027e7a1fd1d445b18073fec9e4fa449c5975086551c51c58dccf8b
4
+ data.tar.gz: 92f3ada6ce7a8617e8a50ddf4a5f11827722845dd952c244547f93e76853c283
5
5
  SHA512:
6
- metadata.gz: ae00b7c9086d4a975e347a57389a179b6c71dece21e16bf6fbd80dfe692b7a85b6204eaff77bf5109a0e02e08e45025ee6b95a3aae2cb4126d8878c575fd12e2
7
- data.tar.gz: d98eba78f597b98c1df33a7f87d1d939153af67267246ec0a4c80363863871e48834cb76af59bc97d9c39994e699e554a9710ec634db96c8d97f3d4c1b7e082d
6
+ metadata.gz: 6d8931cc9b545291cd231cdec1ede213e0838261d3fdcfe19dfd3f71b70c0f83dbf11798573ead47238041bb889e9943abed244cc78661febee80c5ddac9b2ed
7
+ data.tar.gz: 3438431663f57852b0167a85ad4dd9f895198f7854090b4d06e8844c2eba01089d3c0a743a4ff37adf8abe9b4cb02395d9bde6fb8bc17923f95a71b9d5007086
data/Appraisals CHANGED
@@ -1,11 +1,11 @@
1
- appraise 'rails_4.2' do
2
- gem 'rails', '~> 4.2.0'
1
+ appraise 'rails_5.2' do
2
+ gem 'rails', '~> 5.2.0'
3
3
  end
4
4
 
5
- appraise 'rails_5.0' do
6
- gem 'rails', '~> 5.0.0'
5
+ appraise 'rails_6.0' do
6
+ gem 'rails', '~> 6.0.0'
7
7
  end
8
8
 
9
- appraise 'rails_5.1' do
10
- gem 'rails', '~> 5.1.0'
9
+ appraise 'rails_6.1' do
10
+ gem 'rails', '~> 6.1.0'
11
11
  end
data/README.md CHANGED
@@ -20,7 +20,7 @@ For disambiguation: in this README, when you read "Services" with a uppercase "S
20
20
 
21
21
  #### Ruby >= 2.2.5
22
22
 
23
- #### Rails >= 4.2
23
+ #### Rails >= 5.2
24
24
 
25
25
  #### Redis >= 3.0
26
26
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.2.0"
5
+ gem "rails", "~> 5.2.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.0.0"
5
+ gem "rails", "~> 6.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.1.0"
5
+ gem "rails", "~> 6.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -46,10 +46,6 @@ module Services
46
46
  GlobalID::Locator.locate(arg) || arg
47
47
  end
48
48
 
49
- # If the `call` method takes any kwargs and the last argument is a hash, symbolize the hash keys,
50
- # otherwise they won't be recognized as kwards when splatted.
51
- # Since the arguments to `perform` are serialized to the database before Sidekiq picks them up,
52
- # symbol keys are converted to strings.
53
49
  call_method = method(:call)
54
50
 
55
51
  # Find the first class that inherits from `Services::Base`.
@@ -57,11 +53,14 @@ module Services
57
53
  call_method = call_method.super_method
58
54
  end
59
55
 
60
- if call_method.parameters.map(&:first).grep(/\Akey/).any? && args.last.is_a?(Hash)
61
- args.last.symbolize_keys!
56
+ # If the `call` method takes any kwargs and the last argument is a hash, pass them to the method as kwargs.
57
+ kwargs = if call_method.parameters.map(&:first).grep(/\Akey/).any? && args.last.is_a?(Hash)
58
+ args.pop.symbolize_keys
59
+ else
60
+ {}
62
61
  end
63
62
 
64
- call *args
63
+ call *args, **kwargs
65
64
  end
66
65
  end
67
66
  end
data/lib/services/base.rb CHANGED
@@ -25,7 +25,7 @@ module Services
25
25
  @id = SecureRandom.hex(6)
26
26
  end
27
27
 
28
- def call(*args)
28
+ def call(*args, **kwargs)
29
29
  raise NotImplementedError
30
30
  end
31
31
 
@@ -27,9 +27,9 @@ module Services
27
27
  end
28
28
  end
29
29
 
30
- def call(*args)
30
+ def call(*args, **kwargs)
31
31
  unless self.class.call_logging_disabled
32
- log "START with args: #{args}", caller: caller
32
+ log "START with args: #{args}, kwargs: #{kwargs}", caller: caller
33
33
  start = Time.now
34
34
  end
35
35
  begin
@@ -1,7 +1,7 @@
1
1
  module Services
2
2
  class Base
3
3
  module ExceptionWrapper
4
- def call(*args)
4
+ def call(*args, **kwargs)
5
5
  super
6
6
  rescue StandardError => e
7
7
  if e.class <= self.class::Error
@@ -42,7 +42,7 @@ module Services
42
42
  end
43
43
  end
44
44
 
45
- def call(*args)
45
+ def call(*args, **kwargs)
46
46
  @_service_args = args
47
47
  super
48
48
  rescue self.class::NotUniqueError => e
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '7.3.3'.freeze
2
+ VERSION = '8.0.0'.freeze
3
3
  end
@@ -81,14 +81,14 @@ module Services
81
81
  end
82
82
 
83
83
  class EmptyService < Services::Base
84
- def call(*args)
84
+ def call(*args, **kwargs)
85
85
  end
86
86
  end
87
87
 
88
88
  class EmptyServiceWithoutCallLogging < Services::Base
89
89
  disable_call_logging
90
90
 
91
- def call(*args)
91
+ def call(*args, **kwargs)
92
92
  end
93
93
  end
94
94
 
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: 7.3.3
4
+ version: 8.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: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -193,9 +193,9 @@ files:
193
193
  - LICENSE.txt
194
194
  - README.md
195
195
  - Rakefile
196
- - gemfiles/rails_4.2.gemfile
197
- - gemfiles/rails_5.0.gemfile
198
- - gemfiles/rails_5.1.gemfile
196
+ - gemfiles/rails_5.2.gemfile
197
+ - gemfiles/rails_6.0.gemfile
198
+ - gemfiles/rails_6.1.gemfile
199
199
  - lib/services.rb
200
200
  - lib/services/asyncable.rb
201
201
  - lib/services/base.rb
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  requirements: []
249
- rubygems_version: 3.1.3
249
+ rubygems_version: 3.2.11
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: A nifty service layer for your Rails app