ree_lib 1.0.71 → 1.0.72
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0421ad28472f902b4c53091515c749bdcb6aba9ef96ed42009abe27d115edf48
|
4
|
+
data.tar.gz: 3909bfecb3e92e05708a9be5effb672fc8042e2f53ed4aadb426539f0eba8574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb696f99d8af84de496f0e6a3bf616256853302d952409832fd89eb24830c0f29cb2cead19b245eee883a2c9dc7d358633bccc308be56369c2d8aeb569a66c7d
|
7
|
+
data.tar.gz: 0accc79d4259f341f4fbf6306103e28521b070119b2ee6be3e7bb98e08802b78ad857f476524a128d9c51cd7ca02fb59298ac70886b70a1304de8d39455d13d5
|
data/Gemfile.lock
CHANGED
@@ -3,14 +3,12 @@ module ReeDao
|
|
3
3
|
include Ree::LinkDSL
|
4
4
|
include ReeDao::AssociationMethods
|
5
5
|
|
6
|
-
link :demodulize, from: :ree_string
|
7
6
|
link :group_by, from: :ree_array
|
8
7
|
link :index_by, from: :ree_array
|
9
|
-
link :underscore, from: :ree_string
|
10
8
|
|
11
9
|
attr_reader :parent, :parent_dao, :list, :global_opts
|
12
10
|
|
13
|
-
contract(ReeDao::Associations, Sequel::Dataset, Array, Ksplat[RestKeys => Any] => Any)
|
11
|
+
contract(ReeDao::Associations, Nilor[Sequel::Dataset], Array, Ksplat[RestKeys => Any] => Any)
|
14
12
|
def initialize(parent, parent_dao, list, **global_opts)
|
15
13
|
@parent = parent
|
16
14
|
@parent_dao = parent_dao
|
@@ -51,8 +49,7 @@ module ReeDao
|
|
51
49
|
|
52
50
|
dao = if scope.is_a?(Array)
|
53
51
|
return [] if scope.empty?
|
54
|
-
|
55
|
-
find_dao(name, parent, nil)
|
52
|
+
nil
|
56
53
|
else
|
57
54
|
find_dao(assoc_name, parent, scope)
|
58
55
|
end
|
@@ -125,7 +122,7 @@ module ReeDao
|
|
125
122
|
**global_opts
|
126
123
|
)
|
127
124
|
|
128
|
-
if parent_dao.db.in_transaction? || ReeDao::Associations.sync_mode?
|
125
|
+
if parent_dao.nil? || parent_dao.db.in_transaction? || ReeDao::Associations.sync_mode?
|
129
126
|
associations.instance_exec(assoc_list, &block)
|
130
127
|
else
|
131
128
|
threads = associations.instance_exec(assoc_list, &block)
|
@@ -145,7 +142,7 @@ module ReeDao
|
|
145
142
|
end
|
146
143
|
|
147
144
|
contract(
|
148
|
-
Sequel::Dataset,
|
145
|
+
Nilor[Sequel::Dataset],
|
149
146
|
Symbol,
|
150
147
|
Array,
|
151
148
|
Kwargs[
|
@@ -170,7 +167,11 @@ module ReeDao
|
|
170
167
|
if reverse
|
171
168
|
# has_one
|
172
169
|
if !foreign_key
|
173
|
-
|
170
|
+
if parent_dao.nil?
|
171
|
+
raise ArgumentError.new("foreign_key should be provided for :#{assoc_name} association")
|
172
|
+
end
|
173
|
+
|
174
|
+
foreign_key = foreign_key_from_dao(parent_dao)
|
174
175
|
end
|
175
176
|
|
176
177
|
root_ids = list.map(&:id).uniq
|
@@ -206,7 +207,7 @@ module ReeDao
|
|
206
207
|
end
|
207
208
|
|
208
209
|
contract(
|
209
|
-
Sequel::Dataset,
|
210
|
+
Nilor[Sequel::Dataset],
|
210
211
|
Symbol,
|
211
212
|
Array,
|
212
213
|
Kwargs[
|
@@ -228,7 +229,13 @@ module ReeDao
|
|
228
229
|
assoc_dao = nil
|
229
230
|
assoc_dao = find_dao(assoc_name, parent, scope)
|
230
231
|
|
231
|
-
foreign_key
|
232
|
+
if !foreign_key
|
233
|
+
if parent_dao.nil?
|
234
|
+
raise ArgumentError.new("foreign_key should be provided for :#{assoc_name} association")
|
235
|
+
end
|
236
|
+
|
237
|
+
foreign_key = foreign_key_from_dao(parent_dao)
|
238
|
+
end
|
232
239
|
|
233
240
|
root_ids = list.map(&:"#{primary_key}")
|
234
241
|
|
@@ -343,5 +350,11 @@ module ReeDao
|
|
343
350
|
|
344
351
|
parent.agg_caller.send(method, *args, &block)
|
345
352
|
end
|
353
|
+
|
354
|
+
private
|
355
|
+
|
356
|
+
def foreign_key_from_dao(dao)
|
357
|
+
"#{dao.first_source_table.to_s.gsub(/s$/, '')}_id".to_sym
|
358
|
+
end
|
346
359
|
end
|
347
360
|
end
|
@@ -87,7 +87,7 @@ module ReeDao
|
|
87
87
|
Optblock => Any
|
88
88
|
)
|
89
89
|
def association(assoc_type, assoc_name, __opts, &block)
|
90
|
-
if parent_dao.db.in_transaction? || self.class.sync_mode?
|
90
|
+
if parent_dao.nil? || parent_dao.db.in_transaction? || self.class.sync_mode?
|
91
91
|
return if association_is_not_included?(assoc_name) || list.empty?
|
92
92
|
|
93
93
|
association = Association.new(self, parent_dao, list, **global_opts)
|
data/lib/ree_lib/version.rb
CHANGED