services 4.1.2 → 4.1.3

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: 663659a34911d48a176a7a738d1e175eba358a5d
4
- data.tar.gz: 6cce3ab91a8f66904024d2900b7a51eff3d62319
3
+ metadata.gz: fb7f8fa1f247c8cd78f746ed04c37863d306d576
4
+ data.tar.gz: 00477c2e76f2d8c08eb1baa32af0ff826ea35d8b
5
5
  SHA512:
6
- metadata.gz: 323b319f2fd465870696042ba9942561afb10225d444d2659f2e7c064fb5d7610addf44cb708a27b14dc3a7b05460c9d7cdcc1938796b9e76ed1e62f4c4bd517
7
- data.tar.gz: 304566a8682c1f2e9c95b869eddccc9250f573cc62e2f20b2251df291cb8fe2b11300f232716df4e185712ef92e720eda1a3eb71bf85f076a9cbd2956473df6b
6
+ metadata.gz: 6ebc5ae0f75cbdc234dd491f0e83a8ca31acf3f3d2db1028c22b2891a5a255c1601c9b2a944dd084927e7ae3a3c2683d68093458023976ca0e6762fe5c7c5c6c
7
+ data.tar.gz: dd8d2c6ea38ca439d70246adab1345921086bfc41b1c1f341f75dc09b82fafea53fc9d52329c3f163a42b103353822a3af8ec6ebd43fb2a87beec0562b3e261c
data/lib/services/base.rb CHANGED
@@ -46,11 +46,16 @@ module Services
46
46
  ids
47
47
  end
48
48
 
49
+ def find_service(klass)
50
+ find_service_name = "#{klass.to_s.pluralize}::Find"
51
+ candidates = [find_service_name, "Services::#{find_service_name}"]
52
+ candidates.map(&:safe_constantize).compact.first or raise self.class::Error, "Could not find find service (tried: #{candidates.join(', ')})"
53
+ end
54
+
49
55
  def find_objects(ids_or_objects, klass = object_class)
50
56
  ids, objects = _split_ids_and_objects(ids_or_objects, klass)
51
57
  if ids.any?
52
- find_service = "Services::#{klass.to_s.pluralize}::Find"
53
- objects_from_ids = find_service.constantize.call(ids)
58
+ objects_from_ids = find_service(klass).call(ids)
54
59
  object_ids = if objects_from_ids.respond_to?(:pluck)
55
60
  objects_from_ids.pluck(:id)
56
61
  else
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '4.1.2'
2
+ VERSION = '4.1.3'
3
3
  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: 4.1.2
4
+ version: 4.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake