services 6.0.0 → 6.0.1

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: 2d1b3541d084340548b9d3779618d88edcf3c10e50ec42c92f1447aa54621a22
4
- data.tar.gz: fb22582a1c74e144ace44144fb79272d68e0f9f73fadeea69f4ce2947f8bcc10
3
+ metadata.gz: 14581b93267e780498f4371c8b3a5810e122d1137f42bc6bed45149f2cc0881f
4
+ data.tar.gz: 135e7e2cfda92981d940a63fa26c68c092a3560ec5c372aa27c52403b19e0e4c
5
5
  SHA512:
6
- metadata.gz: f62bef4a68d9c9be6b9b9a345f22ee95401cb27c76aaf36a3344af308fbcbc4ba850e670961e0051127624a8e5a1f35eb7d861b695d43cba8c25c284c1bff7c1
7
- data.tar.gz: af9097b696e781fd46c6456a37277a5e0500b70153759faf438f66813071f550a78b615f2bb90e26fc4098dd17d62d203399e96a443ac1a038951494488221ea
6
+ metadata.gz: 9f172dfd9a404b678faff6a7652f78a92410f68a4bf1237defa5be719448cf5ea8e2b62efddd6dd2853955fd6fa22a08063ba0d6e19d2c1e49248948597f06fd
7
+ data.tar.gz: ce9a268f99827c431eab2f05cf12eb72f7d4452766500f16f8d62f274f4ee017daf40bccaa38e8ec652841dafa078a87f39b700afd84d5da4ad816ad2559da74
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.0.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -1,4 +1,5 @@
1
1
  require 'active_support/concern'
2
+ require 'global_id'
2
3
 
3
4
  begin
4
5
  require 'sidekiq'
@@ -14,10 +14,19 @@ module Services
14
14
  end
15
15
  end
16
16
 
17
- def call(ids = [], conditions = {})
18
- raise ArgumentError, 'ids parameter must not be nil.' if ids.nil?
17
+ def call(ids_or_conditions, _conditions = {})
18
+ ids, conditions = if ids_or_conditions.is_a?(Hash)
19
+ if _conditions.any?
20
+ fail ArgumentError, 'If conditions are passed as first argument, there must not be a second argument.'
21
+ end
22
+ [[], ids_or_conditions.symbolize_keys]
23
+ else
24
+ if ids_or_conditions.nil?
25
+ fail ArgumentError, 'IDs must not be nil.'
26
+ end
27
+ [Array(ids_or_conditions), _conditions.symbolize_keys]
28
+ end
19
29
 
20
- ids, conditions = Array(ids), conditions.symbolize_keys
21
30
  object_table_id = "#{object_class.table_name}.id"
22
31
 
23
32
  special_conditions = conditions.extract!(:order, :limit, :page, :per_page)
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '6.0.0'.freeze
2
+ VERSION = '6.0.1'.freeze
3
3
  end
data/services.gemspec CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
@@ -24,7 +22,7 @@ Gem::Specification.new do |gem|
24
22
  gem.add_development_dependency 'rake', '>= 0.9.0'
25
23
  gem.add_development_dependency 'guard-rspec', '~> 4.2'
26
24
  gem.add_development_dependency 'rspec', '~> 3.0'
27
- gem.add_development_dependency 'sidekiq', '~> 4.0'
25
+ gem.add_development_dependency 'sidekiq', '~> 5.0'
28
26
  gem.add_development_dependency 'redis', '~> 3.0'
29
27
  gem.add_development_dependency 'redis-namespace', '~> 1.5'
30
28
  gem.add_development_dependency 'tries', '~> 0.3'
@@ -22,4 +22,12 @@ describe Services::Query do
22
22
  end
23
23
  end
24
24
  end
25
+
26
+ describe 'calling without IDs parameter' do
27
+ let(:post) { Post.create! title: 'Superpost!' }
28
+
29
+ it 'works' do
30
+ expect(Services::Posts::Find.call title: post.title).to eq([post])
31
+ end
32
+ end
25
33
  end
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: 6.0.0
4
+ version: 6.0.1
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-08 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '5.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '5.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redis
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -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.7.1
249
+ rubygems_version: 2.7.3
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: A nifty service layer for your Rails app