Serialization handler methods on PaperTrail::Model::ClassMethods should fall back to current serializer set under Config
This commit is contained in:
parent
67bba87799
commit
4dfd1d4fc0
|
@ -12,6 +12,8 @@ PaperTrail::Rails::Engine.eager_load!
|
|||
[#354](https://github.com/airblade/paper_trail/issues/354) / [#131](https://github.com/airblade/paper_trail/issues/131) -
|
||||
Versions should be built with `after_` callbacks so the timestamp field for a version can be forced to match the
|
||||
corresponding timestamp in the database for the state persistence of a change to the base (versioned) model.
|
||||
- Methods handling serialized attributes should fallback to the currently set Serializer instead of always falling back
|
||||
to `PaperTrail::Serializers::YAML`.
|
||||
|
||||
## 3.0.5
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ module PaperTrail
|
|||
|
||||
serialized_attributes.each do |key, coder|
|
||||
if attributes.key?(key)
|
||||
coder = PaperTrail::Serializers::YAML unless coder.respond_to?(:dump) # Fall back to YAML if `coder` has no `dump` method
|
||||
# Fall back to current serializer if `coder` has no `dump` method
|
||||
coder = PaperTrail.serializer unless coder.respond_to?(:dump)
|
||||
attributes[key] = coder.dump(attributes[key])
|
||||
end
|
||||
end
|
||||
|
@ -127,7 +128,7 @@ module PaperTrail
|
|||
|
||||
serialized_attributes.each do |key, coder|
|
||||
if attributes.key?(key)
|
||||
coder = PaperTrail::Serializers::YAML unless coder.respond_to?(:dump)
|
||||
coder = PaperTrail.serializer unless coder.respond_to?(:dump)
|
||||
attributes[key] = coder.load(attributes[key])
|
||||
end
|
||||
end
|
||||
|
@ -140,7 +141,8 @@ module PaperTrail
|
|||
|
||||
serialized_attributes.each do |key, coder|
|
||||
if changes.key?(key)
|
||||
coder = PaperTrail::Serializers::YAML unless coder.respond_to?(:dump) # Fall back to YAML if `coder` has no `dump` method
|
||||
# Fall back to current serializer if `coder` has no `dump` method
|
||||
coder = PaperTrail.serializer unless coder.respond_to?(:dump)
|
||||
old_value, new_value = changes[key]
|
||||
changes[key] = [coder.dump(old_value),
|
||||
coder.dump(new_value)]
|
||||
|
@ -154,7 +156,7 @@ module PaperTrail
|
|||
|
||||
serialized_attributes.each do |key, coder|
|
||||
if changes.key?(key)
|
||||
coder = PaperTrail::Serializers::YAML unless coder.respond_to?(:dump)
|
||||
coder = PaperTrail.serializer unless coder.respond_to?(:dump)
|
||||
old_value, new_value = changes[key]
|
||||
changes[key] = [coder.load(old_value),
|
||||
coder.load(new_value)]
|
||||
|
|
Loading…
Reference in New Issue