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: bdb25650f338b4be087e72a1ef04fff5b9e1bf47d0b22221ead03743c74de398
4
- data.tar.gz: 333d7adc841964ddd5b50d690f6c016b096622ba327953ae5a5fa57d50f7bde1
3
+ metadata.gz: ae96c3d6f51872601ad8c4a282cc8119e069a49a2942e624a3eed02817bbf450
4
+ data.tar.gz: 962693ff78a273ff60ab20f1e704759038e0402619c84ce2da5735f16cca28ad
5
5
  SHA512:
6
- metadata.gz: 220bc20b778767ec025b5402e7f0fb5a32c2cd15b37373e26af20d5de11529a75b79c745fc9e062b5e27d0bf2c62e0438806aad79950498badebc5f980562825
7
- data.tar.gz: 375223a38b2016acb6d3bf9f45a01b6e286b95b32dcd2ab39fa2f90e4d1758bc12e3409333b9370a1b4c653c0ee6d6e5d1249891d93fbff159e5d8d2ad2dcf66
6
+ metadata.gz: 562c425026b16d0389287831ea2da44c08e79818c4f238e52f8e3ee0bb62bf36bc8e4bbfc75e3dbe658706a0b735c4c3e0e572287048e9a3095055e7183bfa62
7
+ data.tar.gz: 54c6f30b6c62de9a43284fc76fcf432e9b0c70691de5d0aaf074c8b4cdb9b889f816ee8219c2ba4e660684899793db9a1c3cd7f502f5567fbe32d9df105b7a67
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.58)
4
+ ree_lib (1.0.59)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -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
- next if value.nil?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.58"
4
+ VERSION = "1.0.59"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.58
4
+ version: 1.0.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov