Module: PaperTrail::Reifier Private
- Defined in:
- lib/paper_trail/reifier.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.
Given a version record and some options, builds a new model object.
Class Method Summary collapse
-
.reify(version, options) ⇒ Object
private
See ‘VersionConcern#reify` for documentation.
-
.reify_has_manys(transaction_id, model, options = {}) ⇒ Object
private
Restore the
model‘s has_many associations as they were at version_at timestamp We lookup the first child versions after version_at timestamp or in same transaction.
Class Method Details
.reify(version, options) ⇒ 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.
See ‘VersionConcern#reify` for documentation.
15 16 17 18 19 20 21 22 23 |
# File 'lib/paper_trail/reifier.rb', line 15 def reify(version, ) = apply_defaults_to(, version) attrs = version.object_deserialized model = init_model(attrs, , version) reify_attributes(model, version, attrs) model.send "#{model.class.version_association_name}=", version reify_associations(model, , version) model end |
.reify_has_manys(transaction_id, model, options = {}) ⇒ 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.
Restore the model‘s has_many associations as they were at version_at timestamp We lookup the first child versions after version_at timestamp or in same transaction.
29 30 31 32 33 34 35 |
# File 'lib/paper_trail/reifier.rb', line 29 def reify_has_manys(transaction_id, model, = {}) assoc_has_many_through, assoc_has_many_directly = model.class.reflect_on_all_associations(:has_many). partition { |assoc| assoc.[:through] } reify_has_many_associations(transaction_id, assoc_has_many_directly, model, ) reify_has_many_through_associations(transaction_id, assoc_has_many_through, model, ) end |