Module: PaperTrailAssociationTracking::Reifiers::HasManyThrough Private

Defined in:
lib/paper_trail_association_tracking/reifiers/has_many_through.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Reify a single HMT association of ‘model`.

Class Method Summary collapse

Class Method Details

.reify(assoc, model, options, transaction_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/paper_trail_association_tracking/reifiers/has_many_through.rb', line 10

def reify(assoc, model, options, transaction_id)
  # Load the collection of through-models. For example, if `model` is a
  # Chapter, having many Paragraphs through Sections, then
  # `through_collection` will contain Sections.
  through_collection = model.send(assoc.options[:through])

  # Now, given the collection of "through" models (e.g. sections), load
  # the collection of "target" models (e.g. paragraphs)
  collection = collection(through_collection, assoc, options, transaction_id)

  # Finally, assign the `collection` of "target" models, e.g. to
  # `model.paragraphs`.
  model.send(assoc.name).proxy_association.target = collection
end