conjoin 0.0.44 → 0.0.45

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
  SHA1:
3
- metadata.gz: 82f2329fc232dd3b07c0e7fdb0fee34c3913d5d0
4
- data.tar.gz: 882039aa582719f307dbfdb70e80e491e5bb64dd
3
+ metadata.gz: 4018cf046d8a09ddb2a56601a2cc76ba4c95ef67
4
+ data.tar.gz: eee3f521dc8cf7a30f656c958ba9989475481228
5
5
  SHA512:
6
- metadata.gz: 8dfdc892c1bdf7a2e96cca8bceca2aad0a202a979a870cbb8b2e6a84408d486580cd66017c3620be67cec0fc3a616d42bb13053e5f6be2078a0096783466dc91
7
- data.tar.gz: 6f4a18edaa8863e963050505f4fbf64c8f3c1f9b5b59865495bb5a3d80ac7f79766e3cb30480f469bf6be887e9abd279dfa66225523c6f4f0f47f4b893d3dd89
6
+ metadata.gz: 056ada6836139becaa18be8d28941b957a57303e42578fd3d5d16c912c6c16388b920a4b0ada1e89eef0524a65d2f8dfab73a55dbf09bb5d7947b8d6c68d948a
7
+ data.tar.gz: df6ad52f9eef9ed1ae7c8535de604f81efe92bab9d2bb10f84ead9006511d9a898e1a711a4b462ea56efea07d8d418674dc4b3f4384c46135e8058b96d4d0916
@@ -183,193 +183,3 @@ module Conjoin
183
183
  end
184
184
  end
185
185
  end
186
-
187
- # https://github.com/rails/rails/blob/4-1-stable/activerecord/lib/active_record/associations/association_scope.rb#L63
188
- # module ActiveRecord
189
- # module Associations
190
- # class AssociationScope #:nodoc:
191
- # def add_constraints(scope, owner, assoc_klass, refl, tracker)
192
- # chain = refl.chain
193
- # scope_chain = refl.scope_chain
194
- #
195
- # tables = construct_tables(chain, assoc_klass, refl, tracker)
196
- #
197
- # chain.each_with_index do |reflection, i|
198
- # table, foreign_table = tables.shift, tables.first
199
- #
200
- # if reflection.source_macro == :belongs_to
201
- # if reflection.options[:polymorphic]
202
- # key = reflection.association_primary_key(assoc_klass)
203
- # else
204
- # key = reflection.association_primary_key
205
- # end
206
- #
207
- # foreign_key = reflection.foreign_key
208
- # else
209
- # key = reflection.foreign_key
210
- # foreign_key = reflection.active_record_primary_key
211
- # end
212
- #
213
- # if reflection == chain.last
214
- # bind_val = bind scope, table.table_name, key.to_s, owner[foreign_key], tracker
215
- # scope = scope.where(table[key].eq(bind_val))
216
- #
217
- # if reflection.type
218
- # #############################################
219
- # #############################################
220
- # #############################################
221
- # #############################################
222
- # #############################################
223
- # #############################################
224
- # # .gsub(/\w+::/, '')
225
- # # is a fix for polymorphic associations like
226
- # # VendorWizard::VendorGroup so it can work
227
- # # with the _type VendorGroup instead of
228
- # # VendorWizard::VendorGroup
229
- # #############################################
230
- # #############################################
231
- # #############################################
232
- # #############################################
233
- # #############################################
234
- # value = owner.class.base_class.name.gsub(/\w+::/, '')
235
- # #############################################
236
- # bind_val = bind scope, table.table_name, reflection.type.to_s, value, tracker
237
- # scope = scope.where(table[reflection.type].eq(bind_val))
238
- # end
239
- # else
240
- # constraint = table[key].eq(foreign_table[foreign_key])
241
- #
242
- # if reflection.type
243
- # value = chain[i + 1].klass.base_class.name
244
- # bind_val = bind scope, table.table_name, reflection.type.to_s, value, tracker
245
- # scope = scope.where(table[reflection.type].eq(bind_val))
246
- # end
247
- #
248
- # scope = scope.joins(join(foreign_table, constraint))
249
- # end
250
- #
251
- # is_first_chain = i == 0
252
- # klass = is_first_chain ? assoc_klass : reflection.klass
253
- #
254
- # # Exclude the scope of the association itself, because that
255
- # # was already merged in the #scope method.
256
- # scope_chain[i].each do |scope_chain_item|
257
- # item = eval_scope(klass, scope_chain_item, owner)
258
- #
259
- # if scope_chain_item == refl.scope
260
- # scope.merge! item.except(:where, :includes, :bind)
261
- # end
262
- #
263
- # if is_first_chain
264
- # scope.includes! item.includes_values
265
- # end
266
- #
267
- # scope.where_values += item.where_values
268
- # scope.order_values |= item.order_values
269
- # end
270
- # end
271
- #
272
- # scope
273
- # end
274
- # end
275
- # end
276
- # end
277
- # ACTIVERECORD 4.0.3
278
- module ActiveRecord
279
- module Associations
280
- class AssociationScope #:nodoc:
281
- def add_constraints(scope)
282
- tables = construct_tables
283
-
284
- chain.each_with_index do |reflection, i|
285
- table, foreign_table = tables.shift, tables.first
286
-
287
- if reflection.source_macro == :has_and_belongs_to_many
288
- join_table = tables.shift
289
-
290
- scope = scope.joins(join(
291
- join_table,
292
- table[reflection.association_primary_key].
293
- eq(join_table[reflection.association_foreign_key])
294
- ))
295
-
296
- table, foreign_table = join_table, tables.first
297
- end
298
-
299
- if reflection.source_macro == :belongs_to
300
- if reflection.options[:polymorphic]
301
- key = reflection.association_primary_key(self.klass)
302
- else
303
- key = reflection.association_primary_key
304
- end
305
-
306
- foreign_key = reflection.foreign_key
307
- else
308
- key = reflection.foreign_key
309
- foreign_key = reflection.active_record_primary_key
310
- end
311
-
312
- if reflection == chain.last
313
- bind_val = bind scope, table.table_name, key.to_s, owner[foreign_key]
314
- scope = scope.where(table[key].eq(bind_val))
315
-
316
- if reflection.type
317
- #############################################
318
- #############################################
319
- #############################################
320
- #############################################
321
- #############################################
322
- #############################################
323
- # .gsub(/\w+::/, '')
324
- # is a fix for polymorphic associations like
325
- # VendorWizard::VendorGroup so it can work
326
- # with the _type VendorGroup instead of
327
- # VendorWizard::VendorGroup
328
- #############################################
329
- #############################################
330
- #############################################
331
- #############################################
332
- #############################################
333
- value = owner.class.base_class.name.gsub(/\w+::{1}(\w+::\w+)/, '\1')
334
- #############################################
335
- bind_val = bind scope, table.table_name, reflection.type.to_s, value
336
- scope = scope.where(table[reflection.type].eq(bind_val))
337
- end
338
-
339
- else
340
- constraint = table[key].eq(foreign_table[foreign_key])
341
-
342
- if reflection.type
343
- type = chain[i + 1].klass.base_class.name
344
- constraint = constraint.and(table[reflection.type].eq(type))
345
- end
346
-
347
- scope = scope.joins(join(foreign_table, constraint))
348
- end
349
-
350
- is_first_chain = i == 0
351
- klass = is_first_chain ? self.klass : reflection.klass
352
-
353
- # Exclude the scope of the association itself, because that
354
- # was already merged in the #scope method.
355
- scope_chain[i].each do |scope_chain_item|
356
- item = eval_scope(klass, scope_chain_item)
357
-
358
- if scope_chain_item == self.reflection.scope
359
- scope.merge! item.except(:where, :includes)
360
- end
361
-
362
- if is_first_chain
363
- scope.includes! item.includes_values
364
- end
365
-
366
- scope.where_values += item.where_values
367
- scope.order_values |= item.order_values
368
- end
369
- end
370
-
371
- scope
372
- end
373
- end
374
- end
375
- end
@@ -1,3 +1,3 @@
1
1
  module Conjoin
2
- VERSION = "0.0.44"
2
+ VERSION = "0.0.45"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuba