ree_lib 1.0.122 → 1.0.123
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -9
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/association.rb +12 -6
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/agg_spec.rb +8 -10
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/ree_dao_agg_test.rb +6 -27
- data/lib/ree_lib/packages/ree_dto/package/ree_dto/dto/dto_instance_methods.rb +18 -0
- data/lib/ree_lib/packages/ree_dto/spec/ree_dto/dsl_spec.rb +59 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20fb3c9d6a6bc6f163de981a7591c4ba13e07a4077bd81741073e83e6346cdc6
|
4
|
+
data.tar.gz: c03d78b30e2f347f2aa54c1c3dcaa964a84bfa921eb63295cdba0604e0932850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809b66804d318edd659bf8d3c80f4fe881518ab692b9e7887af1c5e790b3d73475f02fb542b4520f8beb60cfcfd7176a7a1283ae50cc071e69cfa2a70a738a86
|
7
|
+
data.tar.gz: 37c8769871641038cb8f17e8773a5ae4f025e87467334cdc5d2286776b37aa2f072457ff0d098d7e207b9f8f8124a15e99c8f13724806fa9d4219ad82da38182
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ree_lib (1.0.
|
4
|
+
ree_lib (1.0.123)
|
5
5
|
bigdecimal (~> 3.1.6)
|
6
6
|
binding_of_caller (~> 1.0.0)
|
7
7
|
i18n (~> 1.14.1)
|
@@ -20,11 +20,11 @@ GEM
|
|
20
20
|
bigdecimal (3.1.8)
|
21
21
|
binding_of_caller (1.0.1)
|
22
22
|
debug_inspector (>= 1.2.0)
|
23
|
-
bootsnap (1.18.
|
23
|
+
bootsnap (1.18.4)
|
24
24
|
msgpack (~> 1.2)
|
25
25
|
commander (5.0.0)
|
26
26
|
highline (~> 3.0.0)
|
27
|
-
concurrent-ruby (1.3.
|
27
|
+
concurrent-ruby (1.3.4)
|
28
28
|
crack (1.0.0)
|
29
29
|
bigdecimal
|
30
30
|
rexml
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
diff-lcs (1.5.1)
|
34
34
|
faker (3.4.2)
|
35
35
|
i18n (>= 1.8.11, < 2)
|
36
|
-
hashdiff (1.1.
|
36
|
+
hashdiff (1.1.1)
|
37
37
|
highline (3.0.1)
|
38
38
|
i18n (1.14.5)
|
39
39
|
concurrent-ruby (~> 1.0)
|
@@ -45,19 +45,21 @@ GEM
|
|
45
45
|
racc (~> 1.4)
|
46
46
|
nokogiri (1.16.7-x86_64-linux)
|
47
47
|
racc (~> 1.4)
|
48
|
-
oj (3.16.
|
48
|
+
oj (3.16.5)
|
49
49
|
bigdecimal (>= 3.0)
|
50
|
+
ostruct (>= 0.2)
|
51
|
+
ostruct (0.6.0)
|
50
52
|
pg (1.5.7)
|
51
53
|
public_suffix (6.0.1)
|
52
|
-
racc (1.8.
|
54
|
+
racc (1.8.1)
|
53
55
|
rack (3.1.7)
|
54
56
|
rack-test (2.1.0)
|
55
57
|
rack (>= 1.3)
|
56
58
|
rainbow (3.1.1)
|
57
59
|
rake (13.2.1)
|
58
|
-
ree (1.0.
|
60
|
+
ree (1.0.45)
|
59
61
|
commander (~> 5.0.0)
|
60
|
-
rexml (3.3.
|
62
|
+
rexml (3.3.6)
|
61
63
|
strscan
|
62
64
|
roda (3.76.0)
|
63
65
|
rack
|
@@ -68,7 +70,7 @@ GEM
|
|
68
70
|
rspec-mocks (~> 3.13.0)
|
69
71
|
rspec-core (3.13.0)
|
70
72
|
rspec-support (~> 3.13.0)
|
71
|
-
rspec-expectations (3.13.
|
73
|
+
rspec-expectations (3.13.2)
|
72
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
75
|
rspec-support (~> 3.13.0)
|
74
76
|
rspec-mocks (3.13.1)
|
@@ -233,7 +233,7 @@ module ReeDao
|
|
233
233
|
foreign_key = foreign_key_from_dao(parent_dao)
|
234
234
|
end
|
235
235
|
|
236
|
-
root_ids = list.map(
|
236
|
+
root_ids = list.map(&primary_key)
|
237
237
|
|
238
238
|
scope ||= assoc_dao
|
239
239
|
scope = scope.where(foreign_key => root_ids)
|
@@ -278,9 +278,12 @@ module ReeDao
|
|
278
278
|
assoc_setter = if setter
|
279
279
|
setter
|
280
280
|
else
|
281
|
-
"
|
281
|
+
"#{assoc_name}="
|
282
282
|
end
|
283
283
|
|
284
|
+
fallback_assoc_setter = nil
|
285
|
+
fallback_fk = nil
|
286
|
+
|
284
287
|
list.each do |item|
|
285
288
|
if setter && setter.is_a?(Proc)
|
286
289
|
if to_dto
|
@@ -305,7 +308,7 @@ module ReeDao
|
|
305
308
|
if reverse
|
306
309
|
primary_key
|
307
310
|
else
|
308
|
-
foreign_key ? foreign_key : "#{assoc_name}_id"
|
311
|
+
foreign_key ? foreign_key : (fallback_fk ||= "#{assoc_name}_id")
|
309
312
|
end
|
310
313
|
end
|
311
314
|
|
@@ -321,10 +324,13 @@ module ReeDao
|
|
321
324
|
|
322
325
|
value = [] if value.nil? && multiple
|
323
326
|
|
324
|
-
|
327
|
+
if item.respond_to?(assoc_setter)
|
325
328
|
item.send(assoc_setter, value)
|
326
|
-
|
327
|
-
item.send(
|
329
|
+
else
|
330
|
+
item.send(
|
331
|
+
fallback_assoc_setter ||= "set_#{assoc_name}",
|
332
|
+
value
|
333
|
+
)
|
328
334
|
end
|
329
335
|
end
|
330
336
|
end
|
@@ -13,14 +13,12 @@ RSpec.describe :agg do
|
|
13
13
|
before :all do
|
14
14
|
connection = build_pg_connection(ReeDaoAggTest::Db::DB_CONFIG)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
connection.drop_table(:reviews, cascade: true) if connection.table_exists?(:reviews)
|
23
|
-
connection.drop_table(:review_authors, cascade: true) if connection.table_exists?(:review_authors)
|
16
|
+
[
|
17
|
+
:organizations, :users, :user_passports, :books, :chapters, :avtorki,
|
18
|
+
:reviews, :review_authors
|
19
|
+
].each do |table|
|
20
|
+
connection.drop_table(table, cascade: true) if connection.table_exists?(table)
|
21
|
+
end
|
24
22
|
|
25
23
|
connection.create_table :organizations do
|
26
24
|
primary_key :id
|
@@ -866,7 +864,7 @@ RSpec.describe :agg do
|
|
866
864
|
|
867
865
|
u = res[0]
|
868
866
|
expect(u.books).to_not eq(nil)
|
869
|
-
expect(u.books[0].chapters).to eq(
|
867
|
+
expect(u.books[0].chapters).to eq([])
|
870
868
|
expect(u.books[0].author).to eq(nil)
|
871
869
|
expect(u.books[0].reviews).to_not eq(nil)
|
872
870
|
expect(u.books[0].reviews[0].review_author).to_not eq(nil)
|
@@ -994,4 +992,4 @@ RSpec.describe :agg do
|
|
994
992
|
ENV.delete('REE_DAO_SYNC_ASSOCIATIONS')
|
995
993
|
}
|
996
994
|
end
|
997
|
-
end
|
995
|
+
end
|
@@ -44,31 +44,10 @@ class ReeDaoAggTest::Book
|
|
44
44
|
field :user_id, Integer
|
45
45
|
field :title, Nilor[String], default: nil
|
46
46
|
|
47
|
-
field :author, Any
|
48
|
-
end
|
49
|
-
|
50
|
-
def set_chapters(chapters)
|
51
|
-
@chapters = chapters; nil
|
52
|
-
end
|
53
|
-
|
54
|
-
def chapters
|
55
|
-
@chapters
|
56
|
-
end
|
57
|
-
|
58
|
-
def set_author(author)
|
59
|
-
@author = author
|
60
|
-
end
|
47
|
+
field :author, Any, default: nil
|
61
48
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def set_reviews(reviews)
|
67
|
-
@reviews = reviews; nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def reviews
|
71
|
-
@reviews
|
49
|
+
collection :chapters, Any
|
50
|
+
collection :reviews, Any
|
72
51
|
end
|
73
52
|
end
|
74
53
|
|
@@ -87,7 +66,7 @@ class ReeDaoAggTest::User
|
|
87
66
|
field :organization, Any, default: nil
|
88
67
|
field :passport, Any, default: nil
|
89
68
|
field :custom_field, Any, default: nil
|
90
|
-
|
69
|
+
|
91
70
|
collection :movies, Any
|
92
71
|
collection :videogames, Any
|
93
72
|
collection :hobbies, Any
|
@@ -100,7 +79,7 @@ class ReeDaoAggTest::User
|
|
100
79
|
end
|
101
80
|
|
102
81
|
[
|
103
|
-
|
82
|
+
|
104
83
|
].each do |attr|
|
105
84
|
define_method("set_#{attr}") do |*args|
|
106
85
|
instance_variable_set("@#{attr}", *args)
|
@@ -509,4 +488,4 @@ class ReeDaoAggTest::ReviewAuthors
|
|
509
488
|
integer :review_id
|
510
489
|
string :name
|
511
490
|
end
|
512
|
-
end
|
491
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative "./field_meta"
|
2
2
|
require "date"
|
3
3
|
|
4
|
+
package_require("ree_object/functions/deep_dup")
|
5
|
+
|
4
6
|
module ReeDto::DtoInstanceMethods
|
5
7
|
include Ree::Contracts::Core
|
6
8
|
include Ree::Contracts::ArgContracts
|
@@ -134,6 +136,22 @@ module ReeDto::DtoInstanceMethods
|
|
134
136
|
end
|
135
137
|
end
|
136
138
|
|
139
|
+
def initialize_copy(_other)
|
140
|
+
deep_dupper = ReeObject::DeepDup.new
|
141
|
+
@_attrs = deep_dupper.call(@_attrs)
|
142
|
+
@collections = deep_dupper.call(@collections) if defined?(@collections)
|
143
|
+
end
|
144
|
+
|
145
|
+
def initialize_dup(_other)
|
146
|
+
super
|
147
|
+
@changed_fields = nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def initialize_clone(_other)
|
151
|
+
super
|
152
|
+
@changed_fields = @changed_fields.dup if defined?(@changed_fields)
|
153
|
+
end
|
154
|
+
|
137
155
|
private
|
138
156
|
|
139
157
|
def inspect_value(v)
|
@@ -182,4 +182,63 @@ RSpec.describe ReeDto::DSL do
|
|
182
182
|
expect(dto.to_h).to eq({ string: "str", with_default: 1 })
|
183
183
|
}
|
184
184
|
end
|
185
|
+
|
186
|
+
describe "#dup" do
|
187
|
+
it {
|
188
|
+
dto = ReeDto::DtoClass.new(string: "str")
|
189
|
+
dto.string = +"changed"
|
190
|
+
expect(dto.changed_fields).to eq([:string])
|
191
|
+
|
192
|
+
dto.numbers = [1]
|
193
|
+
|
194
|
+
dup = dto.dup
|
195
|
+
expect(dup).to eq(dto)
|
196
|
+
expect(dup.object_id).not_to eq(dto.object_id)
|
197
|
+
expect(dup.changed_fields).to eq([])
|
198
|
+
expect(dup.numbers).to eq([1])
|
199
|
+
|
200
|
+
dup.numbers << 2
|
201
|
+
expect(dto.numbers).to eq([1])
|
202
|
+
|
203
|
+
dup.string.concat("2")
|
204
|
+
expect(dto.string).to eq("changed")
|
205
|
+
|
206
|
+
dup.string = "changed3"
|
207
|
+
expect(dto.string).to eq("changed")
|
208
|
+
|
209
|
+
dto.freeze
|
210
|
+
expect(dto.dup.frozen?).to eq(false)
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "#clone" do
|
215
|
+
it {
|
216
|
+
dto = ReeDto::DtoClass.new(string: "str")
|
217
|
+
dto.string = "changed"
|
218
|
+
expect(dto.changed_fields).to eq([:string])
|
219
|
+
|
220
|
+
dto.numbers = [1]
|
221
|
+
|
222
|
+
clone = dto.clone
|
223
|
+
expect(clone).to eq(dto)
|
224
|
+
expect(clone.object_id).not_to eq(dto.object_id)
|
225
|
+
expect(clone.changed_fields).to eq([:string])
|
226
|
+
expect(clone.numbers).to eq([1])
|
227
|
+
|
228
|
+
clone.numbers << 2
|
229
|
+
expect(dto.numbers).to eq([1])
|
230
|
+
|
231
|
+
clone.string.concat("2")
|
232
|
+
expect(dto.string).to eq("changed")
|
233
|
+
|
234
|
+
clone.string = "changed3"
|
235
|
+
expect(dto.string).to eq("changed")
|
236
|
+
|
237
|
+
clone.with_default = 2
|
238
|
+
expect(dto.changed_fields).to eq([:string])
|
239
|
+
|
240
|
+
dto.freeze
|
241
|
+
expect(dto.clone.frozen?).to eq(true)
|
242
|
+
}
|
243
|
+
end
|
185
244
|
end
|
data/lib/ree_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ree_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.123
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|