lib/paper_trail/reifier.rb
# See `VersionConcern#reify` for documentation.
# @api private
See `VersionConcern#reify` for documentation.
See ` VersionConcern#reify ` for documentation .
def reify(version, options)
        options = apply_defaults_to(options, version)
        attrs = version.object_deserialized
         In this situation we constantize the `item_type` to get hold of the
         class...except when the stored object's attributes include a `type`
         key.  If this is the case, the object we belong to is using single
         table inheritance and the `item_type` will be the base class, not the
         actual subclass. If `type` is present but empty, the class is the base
         class.
        if options[:dup] != true && version.item
          model = version.item
          if options[:unversioned_attributes] == :nil
            init_unversioned_attrs(attrs, model)
          end
        else
          klass = version_reification_class(version, attrs)
           The `dup` option always returns a new object, otherwise we should
           attempt to look for the item outside of default scope(s).
          if options[:dup] || (item_found = klass.unscoped.find_by_id(version.item_id)).nil?
            model = klass.new
          elsif options[:unversioned_attributes] == :nil
            model = item_found
            init_unversioned_attrs(attrs, model)
          end
        end
        reify_attributes(model, version, attrs)
        model.send "{model.class.version_association_name}=", version
        reify_associations(model, options, version)
        model
      end
def reify ( version , options ) options = apply_defaults_to ( options , version ) attrs = version . object_deserialized if options [ :dup ] != true && version . item model = version . item if options [ :unversioned_attributes ] == :nil init_unversioned_attrs ( attrs , model ) end else klass = version_reification_class ( version , attrs ) if options [ :dup ] || ( item_found = klass . unscoped . find_by_id ( version . item_id ) ) . nil? model = klass . new elsif options [ :unversioned_attributes ] == :nil model = item_found init_unversioned_attrs ( attrs , model ) end end reify_attributes ( model , version , attrs ) model . send "#{model.class.version_association_name}=" , version reify_associations ( model , options , version ) model end
See `VersionConcern#reify` for documentation.
See ` VersionConcern#reify ` for documentation .
# Normally a polymorphic belongs_to relationship allows us to get the # object we belong to by calling, in this case, `item`.  However this # returns nil if `item` has been destroyed, and we need to be able to # retrieve destroyed objects. # # In this situation we constantize the `item_type` to get hold of the # class...except when the stored object's attributes include a `type` # key.  If this is the case, the object we belong to is using single # table inheritance and the `item_type` will be the base class, not the # actual subclass. If `type` is present but empty, the class is the base # class. # The `dup` option always returns a new object, otherwise we should # attempt to look for the item outside of default scope(s).
version
<not_specific>
options
<not_specific>
api
None