ree_lib 1.0.58 → 1.0.59
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae96c3d6f51872601ad8c4a282cc8119e069a49a2942e624a3eed02817bbf450
|
4
|
+
data.tar.gz: 962693ff78a273ff60ab20f1e704759038e0402619c84ce2da5735f16cca28ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 562c425026b16d0389287831ea2da44c08e79818c4f238e52f8e3ee0bb62bf36bc8e4bbfc75e3dbe658706a0b735c4c3e0e572287048e9a3095055e7183bfa62
|
7
|
+
data.tar.gz: 54c6f30b6c62de9a43284fc76fcf432e9b0c70691de5d0aaf074c8b4cdb9b889f816ee8219c2ba4e660684899793db9a1c3cd7f502f5567fbe32d9df105b7a67
|
data/Gemfile.lock
CHANGED
@@ -242,7 +242,8 @@ module ReeDao
|
|
242
242
|
assoc,
|
243
243
|
assoc_name,
|
244
244
|
setter: setter,
|
245
|
-
primary_key: primary_key
|
245
|
+
primary_key: primary_key,
|
246
|
+
multiple: true
|
246
247
|
)
|
247
248
|
|
248
249
|
assoc
|
@@ -255,10 +256,11 @@ module ReeDao
|
|
255
256
|
Kwargs[
|
256
257
|
primary_key: Nilor[Symbol],
|
257
258
|
reverse: Nilor[Bool],
|
258
|
-
setter: Nilor[Or[Symbol, Proc]]
|
259
|
+
setter: Nilor[Or[Symbol, Proc]],
|
260
|
+
multiple: Bool
|
259
261
|
] => Any
|
260
262
|
)
|
261
|
-
def populate_association(list, association_index, assoc_name, primary_key: nil, reverse: nil, setter: nil)
|
263
|
+
def populate_association(list, association_index, assoc_name, primary_key: nil, reverse: nil, setter: nil, multiple: false)
|
262
264
|
assoc_setter = if setter
|
263
265
|
setter
|
264
266
|
else
|
@@ -275,7 +277,8 @@ module ReeDao
|
|
275
277
|
reverse ? primary_key : "#{assoc_name}_id"
|
276
278
|
end
|
277
279
|
value = association_index[item.send(key)]
|
278
|
-
|
280
|
+
|
281
|
+
value = [] if value.nil? && multiple
|
279
282
|
|
280
283
|
begin
|
281
284
|
item.send(assoc_setter, value)
|
@@ -465,6 +465,49 @@ RSpec.describe :load_agg do
|
|
465
465
|
expect(res_user.custom_field).to_not eq(nil)
|
466
466
|
}
|
467
467
|
|
468
|
+
it {
|
469
|
+
organizations.delete_all
|
470
|
+
users.delete_all
|
471
|
+
user_passports.delete_all
|
472
|
+
books.delete_all
|
473
|
+
chapters.delete_all
|
474
|
+
|
475
|
+
organization = ReeDaoLoadAggTest::Organization.new(name: "Test Org")
|
476
|
+
organizations.put(organization)
|
477
|
+
|
478
|
+
user_1 = ReeDaoLoadAggTest::User.new(name: "John", age: 33, organization_id: organization.id)
|
479
|
+
user_2 = ReeDaoLoadAggTest::User.new(name: "Sam", age: 21, organization_id: organization.id)
|
480
|
+
users.put(user_1)
|
481
|
+
users.put(user_2)
|
482
|
+
|
483
|
+
book_1 = ReeDaoLoadAggTest::Book.new(user_id: user_1.id, title: "1984")
|
484
|
+
book_2 = ReeDaoLoadAggTest::Book.new(user_id: user_1.id, title: "1408")
|
485
|
+
|
486
|
+
books.put(book_1)
|
487
|
+
books.put(book_2)
|
488
|
+
|
489
|
+
author_1 = ReeDaoLoadAggTest::Author.new(book_id: book_1.id, name: "George Orwell")
|
490
|
+
author_2 = ReeDaoLoadAggTest::Author.new(book_id: book_2.id, name: "Stephen King")
|
491
|
+
authors.put(author_1)
|
492
|
+
authors.put(author_2)
|
493
|
+
|
494
|
+
res = users_agg.call(
|
495
|
+
users.all
|
496
|
+
)
|
497
|
+
|
498
|
+
expect(res[0].books.first.author).to_not eq(nil)
|
499
|
+
|
500
|
+
authors.delete(author_1)
|
501
|
+
authors.delete(author_2)
|
502
|
+
|
503
|
+
res = users_agg.call(
|
504
|
+
users.all
|
505
|
+
)
|
506
|
+
|
507
|
+
expect(res[0].books[0].author).to eq(nil)
|
508
|
+
expect(res[0].books[1].author).to eq(nil)
|
509
|
+
}
|
510
|
+
|
468
511
|
it {
|
469
512
|
organizations.delete_all
|
470
513
|
users.delete_all
|
data/lib/ree_lib/version.rb
CHANGED