@@ -77,11 +77,6 @@ def [](index)
7777 ( @collection . length ..index ) . each do |i |
7878 new_dummy_record = ReactiveRecord ::Base . new_from_vector ( @target_klass , nil , *@vector , "*#{ i } " )
7979 new_dummy_record . attributes [ @association . inverse_of ] = @owner if @association && !@association . through_association?
80- <<<<<<< Updated upstream
81- =======
82- # HMT-TODO: the above needs to be looked into... if we are a hmt then don't we need to create a dummy on the joins collection as well?
83- # or maybe this just does not work for HMT?
84- >>>>>>> Stashed changes
8580 @collection << new_dummy_record
8681 end
8782 end
@@ -217,11 +212,7 @@ def related_records_for(record)
217212 return [ ] unless attrs [ @association . inverse_of ] == @owner
218213 if !@association . through_association
219214 [ record ]
220- <<<<<<< Updated upstream
221215 elsif ( source = attrs [ @association . source ] )
222- =======
223- elsif ( source = attrs [ @association . source ] ) && source . is_a? ( @target_klass )
224- >>>>>>> Stashed changes
225216 [ source ]
226217 else
227218 [ ]
@@ -242,12 +233,7 @@ def live_scopes
242233 end
243234
244235 def in_this_collection ( related_records )
245- <<<<<<< Updated upstream
246236 return related_records unless @association
247- =======
248- # HMT-TODO: I don't think we can get a set of related records here with a through association unless they are part of the collection
249- return related_records if !@association || @association . through_association?
250- >>>>>>> Stashed changes
251237 related_records . select do |r |
252238 r . backing_record . attributes [ @association . inverse_of ] == @owner
253239 end
@@ -420,15 +406,7 @@ def push_and_update_belongs_to(id)
420406 def set_belongs_to ( child )
421407 if @owner
422408 # TODO this is major broken...current
423- <<<<<<< Updated upstream
424409 child . send ( "#{ @association . inverse_of } =" , @owner ) if @association && !@association . through_association
425- =======
426- if ( through_association = @association . through_association )
427- # HMT-TODO: create a new record with owner and child
428- else
429- child . send ( "#{ @association . inverse_of } =" , @owner ) if @association && !@association . through_association
430- end
431- >>>>>>> Stashed changes
432410 elsif @parent
433411 @parent . set_belongs_to ( child )
434412 end
@@ -443,7 +421,6 @@ def set_belongs_to(child)
443421
444422 def update_child ( item )
445423 backing_record = item . backing_record
446- <<<<<<< Updated upstream
447424 if backing_record && @owner && @association && !@association . through_association? && item . attributes [ @association . inverse_of ] != @owner
448425 inverse_of = @association . inverse_of
449426 current_association = item . attributes [ inverse_of ]
@@ -452,44 +429,11 @@ def update_child(item)
452429 if current_association && current_association . attributes [ @association . attribute ]
453430 current_association . attributes [ @association . attribute ] . delete ( item )
454431 end
455- =======
456- # HMT TODO: The following && !association.through_association was commented out, causing wrong class items to be added to
457- # associations
458- # Why was it commented out.
459- if backing_record && @owner && @association && item . attributes [ @association . inverse_of ] != @owner && !@association . through_association?
460- inverse_of = @association . inverse_of
461- current_association_value = item . attributes [ inverse_of ]
462- backing_record . virgin = false unless backing_record . data_loading?
463- #backing_record.update_belongs_to(inverse_of, @owner)
464- backing_record . set_belongs_to_via_has_many ( @association , @owner )
465- # following is handled by update_belongs_to and is redundant
466- # unless current_association_value.nil? # might be a dummy value which responds to nil
467- # current_association = @association.inverse.inverse(current_association_value)
468- # current_association_attribute = current_association.attribute
469- # if current_association.collection? && current_association_value.attributes[current_association_attribute]
470- # current_association.attributes[current_association_attribute].delete(item)
471- # end
472- # end
473- >>>>>>> Stashed changes
474432 @owner . backing_record . sync_has_many ( @association . attribute )
475433 end
476434 end
477435
478436 def push ( item )
479- <<<<<<< Updated upstream
480- =======
481- if ( through_association = @association &.through_association )
482- through_association . klass . create ( @association . inverse_of => @owner , @association . source => item )
483- self
484- else
485- _internal_push ( item )
486- end
487- end
488-
489- alias << push
490-
491- def _internal_push ( item )
492- >>>>>>> Stashed changes
493437 item . itself # force get of at least the id
494438 if collection
495439 self . force_push item
@@ -505,11 +449,8 @@ def _internal_push(item)
505449 self
506450 end
507451
508- <<<<<<< Updated upstream
509452 alias << push
510453
511- =======
512- >>>>>>> Stashed changes
513454 def sort! ( *args , &block )
514455 replace ( sort ( *args , &block ) )
515456 end
@@ -582,33 +523,20 @@ def internal_replace(new_array)
582523 if new_array . is_a? Collection
583524 @dummy_collection = new_array . dummy_collection
584525 @dummy_record = new_array . dummy_record
585- <<<<<<< Updated upstream
586526 new_array . collection . each { |item | self << item } if new_array . collection
587527 else
588528 @dummy_collection = @dummy_record = nil
589529 new_array . each { |item | self << item }
590- =======
591- new_array . collection . each { |item | _internal_push item } if new_array . collection
592- else
593- @dummy_collection = @dummy_record = nil
594- new_array . each { |item | _internal_push item }
595- >>>>>>> Stashed changes
596530 end
597531 notify_of_change new_array
598532 end
599533
600534 def delete ( item )
601535 unsaved_children . delete ( item )
602536 notify_of_change (
603- <<<<<<< Updated upstream
604537 if @owner && @association && !@association . through_association?
605538 inverse_of = @association . inverse_of
606539 if ( backing_record = item . backing_record ) && item . attributes [ inverse_of ] == @owner
607- =======
608- if @owner && @association
609- inverse_of = @association . inverse_of
610- if ( backing_record = item . backing_record ) && item . attributes [ inverse_of ] == @owner && !@association . through_association?
611- >>>>>>> Stashed changes
612540 # the if prevents double update if delete is being called from << (see << above)
613541 backing_record . update_belongs_to ( inverse_of , nil )
614542 end
@@ -634,11 +562,6 @@ def loading?
634562 @dummy_collection . loading?
635563 end
636564
637- <<<<<<< Updated upstream
638- def loaded?
639- false && @collection && ( !@dummy_collection || !@dummy_collection . loading? ) && ( !@owner || @owner . id || @vector . length > 1 )
640- end
641- =======
642565 # def loading?
643566 # !@collection || (@dummy_collection && @dummy_collection.loading?) || (@owner && [email protected] && @vector && @vector.length <= 1) 644567 # end
@@ -647,7 +570,6 @@ def loaded?
647570 # @collection && (!@dummy_collection || !@dummy_collection.loading?) && (!@owner || @owner.id || !@vector || @vector.length > 1)
648571 # #false && @collection && (!@dummy_collection || !@dummy_collection.loading?) && (!@owner || @owner.id || @vector.length > 1)
649572 # end
650- >>>>>>> Stashed changes
651573
652574 def empty?
653575 # should be handled by method missing below, but opal-rspec does not deal well
0 commit comments