Module: PaperTrailAssociationTracking::Reifiers::BelongsTo Private

Defined in:
lib/paper_trail_association_tracking/reifiers/belongs_to.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 ‘belongs_to` 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
# File 'lib/paper_trail_association_tracking/reifiers/belongs_to.rb', line 10

def reify(assoc, model, options, transaction_id)
  id = model.send(assoc.foreign_key)
  klass = assoc.polymorphic? ?
            model.send(assoc.foreign_type).constantize : assoc.klass
  version = load_version(klass, id, transaction_id, options[:version_at])
  record = load_record(klass, id, options, version)
  model.send("#{assoc.name}=".to_sym, record)
end