aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/serializers/xml_serializer.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-12-03 01:47:21 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-12-03 01:47:21 +0000
commitc4cb2dd01410417b5ab027aff5d472d68d9cbdb1 (patch)
tree2d1d767c23ef2c9460322f586c52a521c2fa50e5 /activerecord/lib/active_record/serializers/xml_serializer.rb
parentf1047173e8d2ccc3a65ed434445bd2807df86614 (diff)
downloadrails-c4cb2dd01410417b5ab027aff5d472d68d9cbdb1.tar.gz
rails-c4cb2dd01410417b5ab027aff5d472d68d9cbdb1.tar.bz2
rails-c4cb2dd01410417b5ab027aff5d472d68d9cbdb1.zip
Fixed that to_xml should not automatically pass :procs to associations included with :include (closes #10162) [chuyeow]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/serializers/xml_serializer.rb')
-rw-r--r--activerecord/lib/active_record/serializers/xml_serializer.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb
index 693060f06e..84b1a53470 100644
--- a/activerecord/lib/active_record/serializers/xml_serializer.rb
+++ b/activerecord/lib/active_record/serializers/xml_serializer.rb
@@ -1,12 +1,12 @@
module ActiveRecord #:nodoc:
module Serialization
# Builds an XML document to represent the model. Some configuration is
- # available through +options+, however more complicated cases should
+ # available through +options+, however more complicated cases should
# override ActiveRecord's to_xml.
#
- # By default the generated XML document will include the processing
+ # By default the generated XML document will include the processing
# instruction and all object's attributes. For example:
- #
+ #
# <?xml version="1.0" encoding="UTF-8"?>
# <topic>
# <title>The First Topic</title>
@@ -42,7 +42,7 @@ module ActiveRecord #:nodoc:
# <parent-id></parent-id>
# <last-read type="date">2004-04-15</last-read>
# </topic>
- #
+ #
# To include first level associations use :include
#
# firm.to_xml :include => [ :account, :clients ]
@@ -189,8 +189,8 @@ module ActiveRecord #:nodoc:
def add_tag(attribute)
builder.tag!(
- dasherize? ? attribute.name.dasherize : attribute.name,
- attribute.value.to_s,
+ dasherize? ? attribute.name.dasherize : attribute.name,
+ attribute.value.to_s,
attribute.decorations(!options[:skip_types])
)
end
@@ -204,9 +204,9 @@ module ActiveRecord #:nodoc:
else
builder.tag!(tag, :type => :array) do
association_name = association.to_s.singularize
- records.each do |record|
+ records.each do |record|
record.to_xml opts.merge(
- :root => association_name,
+ :root => association_name,
:type => (record.class.to_s.underscore == association_name ? nil : record.class.name)
)
end
@@ -231,7 +231,9 @@ module ActiveRecord #:nodoc:
builder.tag!(*args) do
add_attributes
+ procs = options.delete(:procs)
add_includes { |association, records, opts| add_associations(association, records, opts) }
+ options[:procs] = procs
add_procs
yield builder if block_given?
end