diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-09 21:12:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-09 21:12:28 +0000 |
commit | d872281975b2bdcfcd06e21b55d78c8fb53ba5d1 (patch) | |
tree | 8d380e62fc9df44a12d0132dfcdd58046c05ab8a /activerecord/lib | |
parent | 966c276d6071f8c331f75820f8c2f30d1bba02b2 (diff) | |
download | rails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.tar.gz rails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.tar.bz2 rails-d872281975b2bdcfcd06e21b55d78c8fb53ba5d1.zip |
Fixed to_xml across the board to use nice indention, better skip_attributes workings, no type on strings, and cleaned tests [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3829 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1203068aa8..61f7e94d89 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1504,6 +1504,20 @@ module ActiveRecord #:nodoc: @readonly = true end + # Turns this record into XML + def to_xml(options = {}) + options[:skip_attributes] = Array(options[:skip_attributes]) + options[:skip_attributes] << :type + options[:skip_attributes].collect! { |attribute| attribute.to_s } + + attributes_to_be_xmled = attributes + options[:skip_attributes].each { |attribute_name| attributes_to_be_xmled.delete(attribute_name) } + + options[:root] ||= self.class.to_s.underscore + + attributes_to_be_xmled.to_xml(options) + end + private def create_or_update if new_record? then create else update end |