Permalink
Browse files

Merge pull request #13723 from BlakeMesdag/add-back-syck-deserializat…

…ion-hook

Add back yaml_initialize hook to AR::Core for Syck deserialization support

Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information...
2 parents 0a66a47 + 1240338 commit 17944b3c81514b2e4da79c909f4dbd722bfe6c0b @rafaelfranca rafaelfranca committed Jan 16, 2014
Showing with 20 additions and 0 deletions.
  1. +9 −0 activerecord/CHANGELOG.md
  2. +11 −0 activerecord/lib/active_record/core.rb
@@ -1,3 +1,12 @@
+* Add back `#yaml_initialize` method for Syck deserialization
+
+ `ActiveRecord::Core#yaml_initialize` has been added back to support deserialization using
+ the Syck engine. This is to facilitate migration from Syck to Psych. Serialization support
+ will not been restored for Syck, Psych should be used to serialize YAML once its been
+ parsed with Syck.
+
+ *Blake Mesdag*, *arthurnn*
+
* Make `touch` fire the `after_commit` and `after_rollback` callbacks.
*Harry Brundage*
@@ -373,6 +373,17 @@ def has_transactional_callbacks? # :nodoc:
!_rollback_callbacks.empty? || !_commit_callbacks.empty? || !_create_callbacks.empty?
end
+ # Required to deserialize Syck properly.
+ if YAML.const_defined?(:ENGINE) && YAML::ENGINE.syck?
+ ActiveSupport::Deprecation.warn(
+ "Syck is deprecated and support for serialization has been removed." \
+ " ActiveRecord::Core#yaml_initialize will be removed in 4.1 which will break deserialization support with Syck."
+ )
+ def yaml_initialize(tag, coder) # :nodoc:
+ init_with(coder)
+ end
+ end
+
private
# Updates the attributes on this particular ActiveRecord object so that

0 comments on commit 17944b3

Please sign in to comment.