hanami-model 1.1.0.rc1 → 1.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa67e9dd75be68366898314a21f009c72516403
|
4
|
+
data.tar.gz: 25c3f3892d14131966a71dbe18a9339b5b3c1b69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9244838d4936d70bd1a24d4e8cce9944b91527d96999dee94eb0d5a2bf8d39b62350197cd4ff8f0bd0d10e154687850401b2c92aa89ae54d1a506aa6d069a8f3
|
7
|
+
data.tar.gz: 80b5cef9d91ea29db8312eae0a7659b03333cf49a34a35d0b5e08086af020f1ea0a49f29aa8517aac5716c252edea6ad35f1ad23b0dd1fec0c0e5b1a3945234d
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Hanami::Model
|
2
2
|
A persistence layer for Hanami
|
3
3
|
|
4
|
+
## v1.1.0 - 2017-10-25
|
5
|
+
### Fixed
|
6
|
+
- [Luca Guidi] Ensure associations to always accept objects that are serializable into `::Hash`
|
7
|
+
|
4
8
|
## v1.1.0.rc1 - 2017-10-16
|
5
9
|
### Added
|
6
10
|
- [Marcello Rocha] Added support for associations aliasing via `:as` option (`has_many :users, through: :comments, as: :authors`)
|
@@ -28,7 +32,7 @@ A persistence layer for Hanami
|
|
28
32
|
|
29
33
|
## v1.0.4 - 2017-10-14
|
30
34
|
### Fixed
|
31
|
-
- [Nikita Shilnikov] Keep the dependency on `
|
35
|
+
- [Nikita Shilnikov] Keep the dependency on `rom-sql` at `~> 1.3`, which is compatible with `dry-types` `~> 0.11.0`
|
32
36
|
- [Nikita Shilnikov] Ensure to write Postgres JSON (`PGJSON`) type for nested associated records
|
33
37
|
- [Nikita Shilnikov] Ensure `Repository#select` to work with `Hanami::Model::MappedRelation`
|
34
38
|
|
data/hanami-model.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
spec.required_ruby_version = '>= 2.3.0'
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'hanami-utils', '1.1
|
22
|
-
spec.add_runtime_dependency 'rom', '~> 3.3', '>= 3.3.
|
21
|
+
spec.add_runtime_dependency 'hanami-utils', '~> 1.1'
|
22
|
+
spec.add_runtime_dependency 'rom', '~> 3.3', '>= 3.3.3'
|
23
23
|
spec.add_runtime_dependency 'rom-sql', '~> 1.3', '>= 1.3.5'
|
24
24
|
spec.add_runtime_dependency 'rom-repository', '~> 1.4'
|
25
25
|
spec.add_runtime_dependency 'dry-types', '~> 0.11.0'
|
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler'
|
29
29
|
spec.add_development_dependency 'rake', '~> 12'
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
31
31
|
end
|
@@ -50,7 +50,7 @@ module Hanami
|
|
50
50
|
# @api private
|
51
51
|
def create(data)
|
52
52
|
entity.new(command(:create, aggregate(target), use: [:timestamps])
|
53
|
-
.call(data))
|
53
|
+
.call(serialize(data)))
|
54
54
|
rescue => e
|
55
55
|
raise Hanami::Model::Error.for(e)
|
56
56
|
end
|
@@ -59,7 +59,7 @@ module Hanami
|
|
59
59
|
# @api private
|
60
60
|
def add(data)
|
61
61
|
command(:create, relation(target), use: [:timestamps])
|
62
|
-
.call(associate(data))
|
62
|
+
.call(associate(serialize(data)))
|
63
63
|
rescue => e
|
64
64
|
raise Hanami::Model::Error.for(e)
|
65
65
|
end
|
@@ -202,6 +202,10 @@ module Hanami
|
|
202
202
|
def __new__(new_scope)
|
203
203
|
self.class.new(repository, source, target, subject, new_scope)
|
204
204
|
end
|
205
|
+
|
206
|
+
def serialize(data)
|
207
|
+
Utils::Hash.deep_serialize(data)
|
208
|
+
end
|
205
209
|
end
|
206
210
|
end
|
207
211
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "hanami/utils/hash"
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Model
|
3
5
|
module Associations
|
@@ -49,14 +51,14 @@ module Hanami
|
|
49
51
|
|
50
52
|
def create(data)
|
51
53
|
entity.new(
|
52
|
-
command(:create, aggregate(target), use: [:timestamps]).call(data)
|
54
|
+
command(:create, aggregate(target), use: [:timestamps]).call(serialize(data))
|
53
55
|
)
|
54
56
|
rescue => e
|
55
57
|
raise Hanami::Model::Error.for(e)
|
56
58
|
end
|
57
59
|
|
58
60
|
def add(data)
|
59
|
-
command(:create, relation(target), use: [:timestamps]).call(associate(data))
|
61
|
+
command(:create, relation(target), use: [:timestamps]).call(associate(serialize(data)))
|
60
62
|
rescue => e
|
61
63
|
raise Hanami::Model::Error.for(e)
|
62
64
|
end
|
@@ -65,7 +67,7 @@ module Hanami
|
|
65
67
|
command(:update, relation(target), use: [:timestamps])
|
66
68
|
.by_pk(
|
67
69
|
one.public_send(relation(target).primary_key)
|
68
|
-
).call(data)
|
70
|
+
).call(serialize(data))
|
69
71
|
rescue => e
|
70
72
|
raise Hanami::Model::Error.for(e)
|
71
73
|
end
|
@@ -78,7 +80,7 @@ module Hanami
|
|
78
80
|
def replace(data)
|
79
81
|
repository.transaction do
|
80
82
|
delete
|
81
|
-
add(data)
|
83
|
+
add(serialize(data))
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
@@ -151,6 +153,12 @@ module Hanami
|
|
151
153
|
result = result.where(foreign_key => subject.fetch(primary_key)) unless subject.nil?
|
152
154
|
result.as(Model::MappedRelation.mapper_name)
|
153
155
|
end
|
156
|
+
|
157
|
+
# @since 1.1.0
|
158
|
+
# @api private
|
159
|
+
def serialize(data)
|
160
|
+
Utils::Hash.deep_serialize(data)
|
161
|
+
end
|
154
162
|
end
|
155
163
|
end
|
156
164
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "hanami/utils/hash"
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Model
|
3
5
|
module Associations
|
@@ -5,7 +7,7 @@ module Hanami
|
|
5
7
|
#
|
6
8
|
# @since 0.7.0
|
7
9
|
# @api private
|
8
|
-
class ManyToMany
|
10
|
+
class ManyToMany # rubocop:disable Metrics/ClassLength
|
9
11
|
# @since 0.7.0
|
10
12
|
# @api private
|
11
13
|
def self.schema_type(entity)
|
@@ -67,12 +69,13 @@ module Hanami
|
|
67
69
|
__new__(scope.where(condition))
|
68
70
|
end
|
69
71
|
|
72
|
+
# Return the association table object. Would need an aditional query to return the entity
|
73
|
+
#
|
70
74
|
# @since 1.1.0
|
71
75
|
# @api private
|
72
|
-
# Return the association table object. Would need an aditional query to return the entity
|
73
76
|
def add(*data)
|
74
77
|
command(:create, relation(through), use: [:timestamps])
|
75
|
-
.call(associate(data
|
78
|
+
.call(associate(serialize(data)))
|
76
79
|
rescue => e
|
77
80
|
raise Hanami::Model::Error.for(e)
|
78
81
|
end
|
@@ -186,6 +189,14 @@ module Hanami
|
|
186
189
|
def __new__(new_scope)
|
187
190
|
self.class.new(repository, source, target, subject, new_scope)
|
188
191
|
end
|
192
|
+
|
193
|
+
# @since 1.1.0
|
194
|
+
# @api private
|
195
|
+
def serialize(data)
|
196
|
+
data.map do |d|
|
197
|
+
Utils::Hash.deep_serialize(d)
|
198
|
+
end
|
199
|
+
end
|
189
200
|
end
|
190
201
|
end
|
191
202
|
end
|
data/lib/hanami/model/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-utils
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rom
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '3.3'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 3.3.
|
36
|
+
version: 3.3.3
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.3'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 3.3.
|
46
|
+
version: 3.3.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rom-sql
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,14 +140,14 @@ dependencies:
|
|
140
140
|
requirements:
|
141
141
|
- - "~>"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: '3.
|
143
|
+
version: '3.7'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
146
|
version_requirements: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
148
|
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: '3.
|
150
|
+
version: '3.7'
|
151
151
|
description: A persistence framework with entities and repositories
|
152
152
|
email:
|
153
153
|
- me@lucaguidi.com
|
@@ -215,9 +215,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: 2.3.0
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
|
-
- - "
|
218
|
+
- - ">="
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
220
|
+
version: '0'
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
223
|
rubygems_version: 2.6.13
|