ree_lib 1.0.62 → 1.0.64

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
  SHA256:
3
- metadata.gz: e69b23ef012a6748604d4b82d1d81c791902ee23bc6179d231a340e48289a5d7
4
- data.tar.gz: 6233c958a32bfdeea0efaf5b5692d0e824a5e04d9d334bf002d519b0789d6cc3
3
+ metadata.gz: 58dcd5d4f8eeefdbea1dc995ea2e76734a8dccc6a913354085453ca9a0ddd72e
4
+ data.tar.gz: 1d29d9be3027f3d57e3502e6269ac3cd455e50e5ecdf4b17ea73877b15379423
5
5
  SHA512:
6
- metadata.gz: eee96a99fe5217675f4ff9c3db4915571ae444c7af4a33ca763b786b51a07f77f55fe794aa004688ccfd0f6c00f478631ba100181625de5d5f8d503f62b85edb
7
- data.tar.gz: 1abc64ad140c4901e52f62b9a74f30e16f9fd4364a5e066f5321597c4246b7c5d7e2a0cba0515396b1a18aacd27d786321b17fa29004ed7336fac22a8ee75b06
6
+ metadata.gz: 35b733d5bcaf9f7f837d212c7279c77044f29e11b5e48d0480a879180497f77805b3aa0bf5e17a8b2b1aa991f769a1452fad291d6895436d8d1eca6e9a6a4fb6
7
+ data.tar.gz: '08ec8fe4b53aceff584a515ca820484e59bfa387ae3d5f9c9d21fcdf73afa018d777882f40cab8e6f835fc5eb80ca941977f211614aa0005e10ebcea9fc333c9'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.62)
4
+ ree_lib (1.0.64)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -4,7 +4,6 @@ module ReeDao
4
4
 
5
5
  link :group_by, from: :ree_array
6
6
  link :index_by, from: :ree_array
7
- link :transform_values, from: :ree_hash
8
7
 
9
8
  attr_reader :parent, :parent_dao_name, :list, :global_opts
10
9
 
@@ -163,12 +162,14 @@ module ReeDao
163
162
  assoc_dao = find_dao(assoc_name, parent, scope)
164
163
 
165
164
  if reverse
165
+ # has_one
166
166
  if !foreign_key
167
167
  foreign_key = "#{parent_assoc_name.to_s.gsub(/s$/,'')}_id".to_sym
168
168
  end
169
169
 
170
170
  root_ids = list.map(&:id).uniq
171
171
  else
172
+ # belongs_to
172
173
  if !foreign_key
173
174
  foreign_key = :"#{assoc_name}_id"
174
175
  end
@@ -182,7 +183,6 @@ module ReeDao
182
183
  items = add_scopes(scope, global_opts[assoc_name])
183
184
  end
184
185
 
185
-
186
186
  assoc = index_by(items) { _1.send(reverse ? foreign_key : :id) }
187
187
 
188
188
  populate_association(
@@ -272,8 +272,14 @@ module ReeDao
272
272
  list.each do |item|
273
273
  if setter && setter.is_a?(Proc)
274
274
  if to_dto
275
- assoc_index = transform_values(association_index) do |key, value|
276
- to_dto.call(value)
275
+ assoc_index = {}
276
+
277
+ association_index.each do |key, value|
278
+ if value.is_a?(Array)
279
+ assoc_index[key] = value.map { to_dto.call(_1) }
280
+ else
281
+ assoc_index[key] = to_dto.call(value)
282
+ end
277
283
  end
278
284
 
279
285
  self.instance_exec(item, assoc_index, &assoc_setter)
@@ -290,16 +296,14 @@ module ReeDao
290
296
  value = association_index[item.send(key)]
291
297
 
292
298
  if to_dto && !value.nil?
293
- if value.is_a?(Array)
294
- value = value.map { to_dto.call(_1) }
299
+ value = if value.is_a?(Array)
300
+ value.map { to_dto.call(_1) }
295
301
  else
296
- value = to_dto.call(value)
302
+ to_dto.call(value)
297
303
  end
298
304
  end
299
305
 
300
- if value.nil? && multiple
301
- value = []
302
- end
306
+ value = [] if value.nil? && multiple
303
307
 
304
308
  begin
305
309
  item.send(assoc_setter, value)
@@ -43,7 +43,7 @@ module ReeDao
43
43
  def belongs_to(assoc_name, opts = nil, &block)
44
44
  association(__method__, assoc_name, opts, &block)
45
45
  end
46
-
46
+
47
47
  contract(
48
48
  Symbol,
49
49
  Nilor[Proc, Sequel::Dataset],
@@ -52,7 +52,7 @@ module ReeDao
52
52
  def has_one(assoc_name, opts = nil, &block)
53
53
  association(__method__, assoc_name, opts, &block)
54
54
  end
55
-
55
+
56
56
  contract(
57
57
  Symbol,
58
58
  Nilor[Proc, Sequel::Dataset],
@@ -61,7 +61,7 @@ module ReeDao
61
61
  def has_many(assoc_name, opts = nil, &block)
62
62
  association(__method__, assoc_name, opts, &block)
63
63
  end
64
-
64
+
65
65
  contract(Symbol, Proc => Any)
66
66
  def field(assoc_name, proc)
67
67
  association(__method__, assoc_name, proc)
@@ -83,8 +83,9 @@ module ReeDao
83
83
  def association(assoc_type, assoc_name, opts, &block)
84
84
  if self.class.sync_mode?
85
85
  return if association_is_not_included?(assoc_name) || list.empty?
86
-
86
+
87
87
  association = Association.new(self, parent_dao_name, list, **global_opts)
88
+
88
89
  if assoc_type == :field
89
90
  association.handle_field(assoc_name, opts)
90
91
  else
@@ -92,14 +93,14 @@ module ReeDao
92
93
  end
93
94
  else
94
95
  if association_is_not_included?(assoc_name) || list.empty?
95
- return { association_threads: @assoc_threads, field_threads: @field_threads }
96
+ return { association_threads: @assoc_threads, field_threads: @field_threads }
96
97
  end
97
98
 
98
99
  association = Association.new(self, parent_dao_name, list, **global_opts)
99
100
 
100
101
  if assoc_type == :field
101
102
  field_proc = opts
102
- {
103
+ {
103
104
  association_threads: @assoc_threads,
104
105
  field_threads: @field_threads << [
105
106
  association, field_proc
@@ -125,7 +126,7 @@ module ReeDao
125
126
 
126
127
  if only && !only.include?(assoc_name)
127
128
  return false if autoload_children
128
- return true
129
+ return true
129
130
  end
130
131
  end
131
132
 
@@ -251,7 +251,9 @@ RSpec.describe :load_agg do
251
251
 
252
252
  _users = []
253
253
  st_time = Time.now
254
+
254
255
  puts "Seeding #{NUM_OF_USERS} users..."
256
+
255
257
  NUM_OF_USERS.times do
256
258
  u = ReeDaoLoadAggTest::User.new(
257
259
  name: Faker::Name.name,
@@ -130,8 +130,8 @@ RSpec.describe :load_agg do
130
130
  end
131
131
 
132
132
  def some_method(list)
133
- puts list.map(&:id)
134
- puts list.map { _1.class.name }
133
+ # puts list.map(&:id)
134
+ # puts list.map { _1.class.name }
135
135
  end
136
136
 
137
137
  def passport_opts
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.62"
4
+ VERSION = "1.0.64"
5
5
  end
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.62
4
+ version: 1.0.64
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree