aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/conversions.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-06-21 15:07:15 +0000
committerRick Olson <technoweenie@gmail.com>2007-06-21 15:07:15 +0000
commit9e4461438f8ce584b635aca35579c36537a340ca (patch)
tree8c1b83901b2d7ee52d32eec792e6af1ca807e65f /activesupport/lib/active_support/core_ext/array/conversions.rb
parenteb2e30ef249051713d8122a784d8fbfa378e7ae1 (diff)
downloadrails-9e4461438f8ce584b635aca35579c36537a340ca.tar.gz
rails-9e4461438f8ce584b635aca35579c36537a340ca.tar.bz2
rails-9e4461438f8ce584b635aca35579c36537a340ca.zip
Added proper handling of arrays. Closes #8537 [hasmanyjosh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index a4d056e81c..426e53ea1c 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -63,10 +63,15 @@ module ActiveSupport #:nodoc:
opts = options.merge({ :root => children })
- options[:builder].tag!(root) {
- yield options[:builder] if block_given?
- each { |e| e.to_xml(opts.merge!({ :skip_instruct => true })) }
- }
+ xml = options[:builder]
+ if empty?
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"})
+ else
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
+ yield xml if block_given?
+ each { |e| e.to_xml(opts.merge!({ :skip_instruct => true })) }
+ }
+ end
end
end