Please sign in to comment.
ActiveModel support for the :include serialization option
This commit moves support for the :include serialization option for serializing associated objects out of ActiveRecord in into ActiveModel. The following methods support the :include option: * serializable_hash * to_json * to_xml Instances must respond to methods named by the values of the :includes array (or keys of the :includes hash). If an association method returns an object that is_a?(Enumerable) (which AR has_many associations do), it is assumed to be a collection association, and its elements must respond to :serializable_hash. Otherwise it must respond to :serializable_hash itself. While here, fix #858, XmlSerializer should not singularize already singular association names.
- Loading branch information...
Showing with 190 additions and 90 deletions.
- +32 −1 activemodel/lib/active_model/serialization.rb
- +40 −0 activemodel/lib/active_model/serializers/xml.rb
- +67 −6 activemodel/test/cases/serialization_test.rb
- +50 −2 activemodel/test/cases/serializers/xml_serialization_test.rb
- +1 −39 activerecord/lib/active_record/serialization.rb
- +0 −42 activerecord/lib/active_record/serializers/xml_serializer.rb