Class: ActiveRecord::Associations::JoinDependency

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_bulkoperation/active_record/associations/associations.rb

Overview

:nodoc:

Defined Under Namespace

Classes: JoinBase

Instance Method Summary collapse

Instance Method Details

#instantiate_each(row, &block) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/activerecord_bulkoperation/active_record/associations/associations.rb', line 138

def instantiate_each(row, &block)
  if row
    primary_id = join_base.record_id(row)
    unless @base_records_hash[primary_id]
      if @base_records_in_order.size > 0
        yield @base_records_in_order.first
        # Die Theorie ist hier ein primary_key der Haupttabelle
        # ist verarbeitet und nun kann der Satz entsorgt werden.
        @base_records_in_order.pop
        # instatiate_each nicht das gesamte Ergebnis durchsucht,
        # wird @base_record_hash nur fuer den Gruppenwechsel
        # verwendet.
        # Bei einem neuen primary_key wird der Hash geleert.
        @base_records_hash = {}
        # record cache leeren
        # join_base.cached_record = {}
        @joins.each { |j| j.cached_record = {} }
      end
      #RP TODO check if instantiate call is correct with an empty hash or where to get the 2nd parameter
      @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(row,{}))
    end
    construct(@base_records_hash[primary_id], @associations, join_associations.dup, row)
  else
    yield @base_records_in_order.first
  end
end