ree_lib 1.0.62 → 1.0.64
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/association.rb +14 -10
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/associations.rb +8 -7
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/load_agg_benchmark_spec.rb +2 -0
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/load_agg_spec.rb +2 -2
- 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: 58dcd5d4f8eeefdbea1dc995ea2e76734a8dccc6a913354085453ca9a0ddd72e
|
4
|
+
data.tar.gz: 1d29d9be3027f3d57e3502e6269ac3cd455e50e5ecdf4b17ea73877b15379423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35b733d5bcaf9f7f837d212c7279c77044f29e11b5e48d0480a879180497f77805b3aa0bf5e17a8b2b1aa991f769a1452fad291d6895436d8d1eca6e9a6a4fb6
|
7
|
+
data.tar.gz: '08ec8fe4b53aceff584a515ca820484e59bfa387ae3d5f9c9d21fcdf73afa018d777882f40cab8e6f835fc5eb80ca941977f211614aa0005e10ebcea9fc333c9'
|
data/Gemfile.lock
CHANGED
@@ -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 =
|
276
|
-
|
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
|
299
|
+
value = if value.is_a?(Array)
|
300
|
+
value.map { to_dto.call(_1) }
|
295
301
|
else
|
296
|
-
|
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
|
|
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.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-
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|