rom-core 5.0.1 → 5.0.2

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: 7a3f6e2d5a5766b74211f597f8c770b4ec40b5bd1854713362d2aadf34771cc1
4
- data.tar.gz: 91d1f31afbaed20b9069c65cd1f49800f9fd51a2667171545622183bb7e40100
3
+ metadata.gz: bccec1ca22ee806eff149f4e61c1c6cf75eed1dfb1944ee7635239fdff7d7d26
4
+ data.tar.gz: 6ed39c371e2541d83e0060df63278444b852713f3c8a177242b1c41bbbeb14cb
5
5
  SHA512:
6
- metadata.gz: 477a287ed6a51fc9d8a471d10bf1d7fa58e303e1eb74889c40e87d1ff81e6b24228d89b63cd2e99050460bb3f66dd5463132247e758204eb151d769194d47065
7
- data.tar.gz: d92fe3590ddbae8511705100c4bb91c5539dd54a987a461e12e41e5faab35d28a31852faf58b6494a9ee7172ccf564a0f44f643c2da5a95914069b1b6fd36257
6
+ metadata.gz: 4f53fba8d16d7483f9b1779bcf461b71c4d3ed7cde17466765e022284a310c61947317340380ca8d9065ac8a4a0741d0c777b55f161d085355aa67a52d062f9e
7
+ data.tar.gz: e1508e8c595774a991c7a57eaa15bff719b83a022c768cc1f7e05931001321045524975ade75295c8e6963882cfe78f03f5f7dae4111916248f3364b2780200e
@@ -22,6 +22,8 @@ module ROM
22
22
 
23
23
  extend Initializer
24
24
 
25
+ META_OPTIONS = %i[primary_key foreign_key source target relation].freeze
26
+
25
27
  # @!attribute [r] type
26
28
  # @return [Dry::Types::Nominal, Dry::Types::Sum, Dry::Types::Constrained] The attribute's type object
27
29
  param :type
@@ -34,22 +34,6 @@ module ROM
34
34
  # @param [Symbol] adapter The adapter identifier
35
35
  defines :adapter
36
36
 
37
- # @!method self.mapper_compiler
38
- # Get or set gateway-specific mapper compiler class
39
- #
40
- # @overload mapper_compiler
41
- # Return mapper compiler class
42
- # @return [Class]
43
- #
44
- # @overload mapper_compiler(klass)
45
- # @example
46
- # class MyGateway < ROM::Gateway
47
- # mapper_compiler MyMapperCompiler
48
- # end
49
- #
50
- # @param [Class] klass The mapper compiler class
51
- defines :mapper_compiler
52
-
53
37
  # @!attribute [r] connection
54
38
  # @return [Object] The gateway's connection object (type varies across adapters)
55
39
  attr_reader :connection
@@ -106,17 +90,15 @@ module ROM
106
90
  when Symbol
107
91
  klass = class_from_symbol(gateway_or_scheme)
108
92
 
109
- if klass.instance_method(:initialize).arity == 0
93
+ if klass.instance_method(:initialize).arity.zero?
110
94
  klass.new
111
95
  else
112
96
  klass.new(*args)
113
97
  end
114
98
  else
115
- if args.empty?
116
- gateway_or_scheme
117
- else
118
- raise ArgumentError, "Can't accept arguments when passing an instance"
119
- end
99
+ raise ArgumentError, "Can't accept arguments when passing an instance" unless args.empty?
100
+
101
+ gateway_or_scheme
120
102
  end
121
103
  end
122
104
 
@@ -128,7 +110,7 @@ module ROM
128
110
  #
129
111
  # @api private
130
112
  def self.class_from_symbol(type)
131
- adapter = ROM.adapters.fetch(type) {
113
+ adapter = ROM.adapters.fetch(type) do
132
114
  begin
133
115
  require "rom/#{type}"
134
116
  rescue LoadError
@@ -136,7 +118,7 @@ module ROM
136
118
  end
137
119
 
138
120
  ROM.adapters.fetch(type)
139
- }
121
+ end
140
122
 
141
123
  adapter.const_get(:Gateway)
142
124
  end
@@ -196,15 +178,6 @@ module ROM
196
178
  transaction_runner(opts).run(opts, &block)
197
179
  end
198
180
 
199
- # Return configured mapper compiler class
200
- #
201
- # @return [Class]
202
- #
203
- # @api private
204
- def mapper_compiler
205
- self.class.mapper_compiler
206
- end
207
-
208
181
  private
209
182
 
210
183
  # @api private
@@ -14,15 +14,25 @@ module ROM
14
14
 
15
15
  # Create a new relation combined with others
16
16
  #
17
- # @param [Relation] root
17
+ # @param [Relation] relation
18
18
  # @param [Array<Relation>] nodes
19
19
  #
20
20
  # @return [Combined]
21
21
  #
22
22
  # @api public
23
- def self.new(root, nodes)
24
- root_ns = root.options[:struct_namespace]
25
- super(root, nodes.map { |node| node.struct_namespace(root_ns) })
23
+ def self.new(relation, nodes)
24
+ struct_ns = relation.options[:struct_namespace]
25
+ new_nodes = nodes.map { |node| node.struct_namespace(struct_ns) }
26
+
27
+ root =
28
+ if relation.is_a?(self)
29
+ new_nodes.concat(relation.nodes)
30
+ relation.root
31
+ else
32
+ relation
33
+ end
34
+
35
+ super(root, new_nodes)
26
36
  end
27
37
 
28
38
  # Combine this graph with more nodes
@@ -142,7 +152,7 @@ module ROM
142
152
 
143
153
  # @api private
144
154
  def decorate?(other)
145
- super || other.is_a?(Wrap)
155
+ super || other.is_a?(self.class) || other.is_a?(Wrap)
146
156
  end
147
157
  end
148
158
  end
@@ -149,7 +149,7 @@ module ROM
149
149
  type.meta(source: relation, read: type.meta[:read].optional)
150
150
  else
151
151
  type.meta(source: relation)
152
- end
152
+ end.meta(Attribute::META_OPTIONS.map { |opt| [opt, options[opt]] if options.key?(opt) }.compact.to_h)
153
153
  end
154
154
 
155
155
  # Specify which key(s) should be the primary key
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ROM
4
4
  module Core
5
- VERSION = '5.0.1'
5
+ VERSION = '5.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby