rom-repository 1.3.3 → 1.4.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
  SHA1:
3
- metadata.gz: 2939fe9e61cbec70da58fe863b4c49384feabf57
4
- data.tar.gz: 7cf8ca8cfc9acb006d2065bcdfcd6fcac6c4531e
3
+ metadata.gz: 60e1932a1540f3a5db52bbb5a4ae073b83ee0289
4
+ data.tar.gz: 8a430f76a00792c4d12d94d8271b0736310dc20b
5
5
  SHA512:
6
- metadata.gz: 8ee593244830ea931207b4acd726c9475543e6f8dd1bf65a3741c51f75bc1eee9fee974509fc4298005e2958500c38e2e313ed639b63f564de178cb4eb5bdb08
7
- data.tar.gz: e3c05763d9d382a268ee5d29af29472826c86ac538b3b4364b80a36379ecb5d822aa5ced697fb836a111a212c700c24694c13f73f6acd0de6c04dcdd5dac145f
6
+ metadata.gz: 514906df2e8c7c3b33fb3cce5083d65f4b238ca1aa7ca03df9d736f0ceb4752b610d66937e372645cc0f71dd7a0d845cbcdeca27a69a8ca13a367bf75a42b3e8
7
+ data.tar.gz: a75e84fd982d615e4f57802a130658d5d0482c62bf0216f6cf70c6c348c4b99d50561cdcd33de73f6b7ff3700fc15702d4023711b2fe0c0c599b184dc45a77b4
@@ -1,12 +1,18 @@
1
+ # v1.4.0 2017-07-04
2
+
3
+ ### Added
4
+
5
+ * `Relation#map_to` available in repository relations to ease upgrade to rom 4.0 (solnic)
6
+ * Deprecation warnings in preparation for rom 4.0 release (solnic)
7
+
8
+ [Compare v1.3.3...v1.3.4](https://github.com/rom-rb/rom-repository/compare/v1.3.3...v1.3.4)
9
+
1
10
  # v1.3.3 2017-05-31
2
11
 
3
12
  ### Added
4
13
 
5
- * `Changeset#extend` to exclude steps from the `#diff` output, this allows
6
- to filter out timestamp changes prior to updates so that we can avoid
7
- hitting the database in case of timestamp-only changes. You still can call `.map(:touch)`
8
- if you want to have `updated_at` refreshed unconditionally (flash-gordon)
9
-
14
+ * `Changeset#extend` to exclude steps from the `#diff` output, this allows to filter out timestamp changes prior to updates so that we can avoid hitting the database in case of timestamp-only changes. You still can call `.map(:touch)` if you want to have `updated_at` refreshed unconditionally (flash-gordon)
15
+
10
16
  ## Fixed
11
17
 
12
18
  * `aggregate` and `combine` works correctly with nested graph options where associations are aliased (solnic)
@@ -125,7 +125,8 @@ module ROM
125
125
 
126
126
  @relations = RelationRegistry.new do |registry, relations|
127
127
  self.class.relations.each do |name|
128
- relation = container.relation(name)
128
+ relation = container.relations[name]
129
+ relation = relation.with(mappers: container.mappers[name]) if container.mappers.key?(name)
129
130
 
130
131
  proxy = RelationProxy.new(
131
132
  relation, name: name, mappers: mappers, registry: registry, auto_struct: auto_struct
@@ -1,3 +1,5 @@
1
+ require 'dry/core/deprecations'
2
+
1
3
  require 'rom/initializer'
2
4
  require 'rom/relation/materializable'
3
5
 
@@ -15,6 +17,8 @@ module ROM
15
17
  # @api public
16
18
  class RelationProxy
17
19
  extend Initializer
20
+ extend Dry::Core::Deprecations[:rom]
21
+
18
22
  include Relation::Materializable
19
23
 
20
24
  (Kernel.private_instance_methods - %i(raise)).each(&method(:undef_method))
@@ -22,6 +26,10 @@ module ROM
22
26
  include RelationProxy::Combine
23
27
  include RelationProxy::Wrap
24
28
 
29
+ deprecate :combine_parents
30
+ deprecate :combine_children
31
+ deprecate :wrap_parent
32
+
25
33
  RelationRegistryType = Types.Definition(RelationRegistry).constrained(type: RelationRegistry)
26
34
 
27
35
  # @!attribute [r] relation
@@ -89,7 +97,31 @@ module ROM
89
97
  # @api public
90
98
  def map_with(*names, **opts)
91
99
  if names.size == 1 && names[0].is_a?(Class)
92
- with(meta: meta.merge(model: names[0]))
100
+ map_to(names[0])
101
+ elsif names.size > 1 && names.any? { |name| name.is_a?(Class) }
102
+ raise ArgumentError, 'using custom mappers and a model is not supported'
103
+ else
104
+ if opts[:auto_map] && !meta[:combine_type]
105
+ mappers = [mapper, *names.map { |name| relation.mappers[name] }]
106
+ mappers.reduce(self) { |a, e| a >> e }
107
+ else
108
+ names.reduce(self) { |a, e| a >> relation.mappers[e] }
109
+ end
110
+ end
111
+ end
112
+
113
+ # @api public
114
+ def as(*names, **opts)
115
+ if names.size == 1 && names[0].is_a?(Class)
116
+ msg = <<-STR
117
+ Relation#as will change behavior in 4.0. Use `map_to` instead
118
+ => Called at:
119
+ #{Kernel.caller[0..5].join("\n")}
120
+ STR
121
+
122
+ Dry::Core::Deprecations.warn(msg)
123
+
124
+ map_to(names[0])
93
125
  elsif names.size > 1 && names.any? { |name| name.is_a?(Class) }
94
126
  raise ArgumentError, 'using custom mappers and a model is not supported'
95
127
  else
@@ -101,7 +133,11 @@ module ROM
101
133
  end
102
134
  end
103
135
  end
104
- alias_method :as, :map_with
136
+
137
+ # @api public
138
+ def map_to(model)
139
+ with(meta: meta.merge(model: model))
140
+ end
105
141
 
106
142
  # Return a new graph with adjusted node returned from a block
107
143
  #
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  class Repository
3
- VERSION = '1.3.3'.freeze
3
+ VERSION = '1.4.0'.freeze
4
4
  end
5
5
  end
@@ -90,12 +90,23 @@ module ROM
90
90
  __send__(name)
91
91
  end
92
92
 
93
+ if RUBY_VERSION < '2.3'
94
+ # @api private
95
+ def respond_to?(*)
96
+ super
97
+ end
98
+ else
99
+ # @api private
100
+ def respond_to_missing?(*)
101
+ super
102
+ end
103
+ end
104
+
93
105
  private
94
106
 
95
107
  def method_missing(method, *)
96
108
  super
97
109
  rescue NameError => error
98
- raise if method == :to_ary
99
110
  raise MissingAttribute.new("#{ error.message } (not loaded attribute?)")
100
111
  end
101
112
  end
@@ -13,10 +13,10 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {spec}/*`.split("\n")
14
14
  gem.license = 'MIT'
15
15
 
16
- gem.add_runtime_dependency 'rom', '~> 3.2', '>= 3.2.3'
16
+ gem.add_runtime_dependency 'rom', '~> 3.3'
17
17
  gem.add_runtime_dependency 'rom-mapper', '~> 0.5'
18
18
  gem.add_runtime_dependency 'dry-core', '~> 0.3', '>= 0.3.1'
19
- gem.add_runtime_dependency 'dry-struct', '~> 0.1'
19
+ gem.add_runtime_dependency 'dry-struct', '~> 0.3'
20
20
 
21
21
  gem.add_development_dependency 'rake', '~> 11.2'
22
22
  gem.add_development_dependency 'rspec', '~> 3.5'
@@ -24,18 +24,15 @@ RSpec.describe 'Repository with multi-adapters configuration' do
24
24
 
25
25
  module Test
26
26
  class Users < ROM::Relation[:sql]
27
- gateway :default
28
- schema(:users, infer: true)
29
- register_as :sql_users
27
+ schema(:users, as: :sql_users, infer: true)
30
28
  end
31
29
 
32
30
  class Tasks < ROM::Relation[:memory]
33
- schema(:tasks) do
31
+ schema(:tasks, as: :memory_tasks) do
34
32
  attribute :user_id, ROM::Types::Int
35
33
  attribute :title, ROM::Types::String
36
34
  end
37
35
 
38
- register_as :memory_tasks
39
36
  gateway :memory
40
37
 
41
38
  use :key_inference
@@ -1,9 +1,9 @@
1
1
  RSpec.shared_context 'relations' do
2
- let(:users) { rom.relation(:users) }
3
- let(:tasks) { rom.relation(:tasks) }
4
- let(:tags) { rom.relation(:tags) }
5
- let(:posts) { rom.relation(:posts) }
6
- let(:books) { rom.relation(:books) }
2
+ let(:users) { rom.relations[:users] }
3
+ let(:tasks) { rom.relations[:tasks] }
4
+ let(:tags) { rom.relations[:tags] }
5
+ let(:posts) { rom.relations[:posts] }
6
+ let(:books) { rom.relations[:books] }
7
7
 
8
8
  before do
9
9
  configuration.relation(:books) do
@@ -96,9 +96,7 @@ RSpec.shared_context 'relations' do
96
96
  end
97
97
 
98
98
  configuration.relation(:comments) do
99
- register_as :comments
100
-
101
- schema(:messages, infer: true) do
99
+ schema(:messages, as: :comments, infer: true) do
102
100
  associations do
103
101
  has_many :reactions, relation: :likes
104
102
  has_many :reactions, relation: :likes, as: :emotions
@@ -107,9 +105,7 @@ RSpec.shared_context 'relations' do
107
105
  end
108
106
 
109
107
  configuration.relation(:likes) do
110
- register_as :likes
111
-
112
- schema(:reactions, infer: true) do
108
+ schema(:reactions, as: :likes, infer: true) do
113
109
  associations do
114
110
  belongs_to :message, relation: :comments
115
111
  end
@@ -8,15 +8,15 @@ RSpec.describe 'loading proxy' do
8
8
  include_context 'seeds'
9
9
 
10
10
  let(:users_proxy) do
11
- ROM::Repository::RelationProxy.new(users, name: :users)
11
+ repo.users
12
12
  end
13
13
 
14
14
  let(:tasks_proxy) do
15
- ROM::Repository::RelationProxy.new(tasks, name: :tasks)
15
+ repo.tasks
16
16
  end
17
17
 
18
18
  let(:tags_proxy) do
19
- ROM::Repository::RelationProxy.new(tags, name: :tags)
19
+ repo.tags
20
20
  end
21
21
 
22
22
  describe '#inspect' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-repository
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rom
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 3.2.3
19
+ version: '3.3'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '3.2'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 3.2.3
26
+ version: '3.3'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rom-mapper
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +64,14 @@ dependencies:
70
64
  requirements:
71
65
  - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: '0.1'
67
+ version: '0.3'
74
68
  type: :runtime
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - "~>"
79
73
  - !ruby/object:Gem::Version
80
- version: '0.1'
74
+ version: '0.3'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: rake
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -197,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
191
  version: '0'
198
192
  requirements: []
199
193
  rubyforge_project:
200
- rubygems_version: 2.6.11
194
+ rubygems_version: 2.6.12
201
195
  signing_key:
202
196
  specification_version: 4
203
197
  summary: Repository abstraction for rom-rb