lib/paper_trail/reifier.rb
# Set all the attributes in this version on the model.
Set all the attributes in this version on the model.
Set all the attributes in this version on the model .
def reify_attributes(model, version, attrs)
        enums = model.class.respond_to?(:defined_enums) ? model.class.defined_enums : {}
        AttributeSerializers::ObjectAttribute.new(model.class).deserialize(attrs)
        attrs.each do |k, v|
          is_enum_without_type_caster = ::ActiveRecord::VERSION::MAJOR < 5 && enums.key?(k)
          if model.has_attribute?(k) && !is_enum_without_type_caster
            model[k.to_sym] = v
          elsif model.respond_to?("#{k}=")
            model.send("#{k}=", v)
          else
            version.logger.warn(
              "Attribute #{k} does not exist on #{version.item_type} (Version id: #{version.id})."
            )
          end
        end
      end
def reify_attributes ( model , version , attrs ) enums = model . class . respond_to? ( :defined_enums ) ? model . class . defined_enums : { } AttributeSerializers :: ObjectAttribute . new ( model . class ) . deserialize ( attrs ) attrs . each do | k , v | is_enum_without_type_caster = :: ActiveRecord :: VERSION :: MAJOR < 5 && enums . key? ( k ) if model . has_attribute? ( k ) && ! is_enum_without_type_caster model [ k . to_sym ] = v elsif model . respond_to? ( "#{k}=" ) model . send ( "#{k}=" , v ) else version . logger . warn ( "Attribute #{k} does not exist on #{version.item_type} (Version id: #{version.id})." ) end end end
Set all the attributes in this version on the model.
Set all the attributes in this version on the model .
# `ObjectAttribute#deserialize` will return the mapped enum value # and in Rails < 5, the []= uses the integer type caster from the column # definition (in general) and thus will turn a (usually) string to 0 instead # of the correct value
model
<not_specific>
version
<not_specific>
attrs
<not_specific>