Changeset 8258 for trunk/activerecord/lib/active_record/serializers
- Timestamp:
- 12/03/07 01:47:21 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/serializers/xml_serializer.rb
r8138 r8258 2 2 module Serialization 3 3 # Builds an XML document to represent the model. Some configuration is 4 # available through +options+, however more complicated cases should 4 # available through +options+, however more complicated cases should 5 5 # override ActiveRecord's to_xml. 6 6 # 7 # By default the generated XML document will include the processing 7 # By default the generated XML document will include the processing 8 8 # instruction and all object's attributes. For example: 9 # 9 # 10 10 # <?xml version="1.0" encoding="UTF-8"?> 11 11 # <topic> … … 43 43 # <last-read type="date">2004-04-15</last-read> 44 44 # </topic> 45 # 45 # 46 46 # To include first level associations use :include 47 47 # … … 190 190 def add_tag(attribute) 191 191 builder.tag!( 192 dasherize? ? attribute.name.dasherize : attribute.name, 193 attribute.value.to_s, 192 dasherize? ? attribute.name.dasherize : attribute.name, 193 attribute.value.to_s, 194 194 attribute.decorations(!options[:skip_types]) 195 195 ) … … 205 205 builder.tag!(tag, :type => :array) do 206 206 association_name = association.to_s.singularize 207 records.each do |record| 207 records.each do |record| 208 208 record.to_xml opts.merge( 209 :root => association_name, 209 :root => association_name, 210 210 :type => (record.class.to_s.underscore == association_name ? nil : record.class.name) 211 211 ) … … 232 232 builder.tag!(*args) do 233 233 add_attributes 234 procs = options.delete(:procs) 234 235 add_includes { |association, records, opts| add_associations(association, records, opts) } 236 options[:procs] = procs 235 237 add_procs 236 238 yield builder if block_given?