aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/serializers/xml_serializer.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-07-04 20:16:36 +0200
committerJosé Valim <jose.valim@gmail.com>2009-07-04 20:16:36 +0200
commit20e2140ce7cd6ece8769fb09a7e615e961446b02 (patch)
tree2bf6a38b51863d86b195551ed740bde719c9d460 /activerecord/lib/active_record/serializers/xml_serializer.rb
parent44633dc7a587424d21917413500b2d71fa3d31bb (diff)
parent783db25e0c640c1588732967a87d65c10fddc08e (diff)
downloadrails-20e2140ce7cd6ece8769fb09a7e615e961446b02.tar.gz
rails-20e2140ce7cd6ece8769fb09a7e615e961446b02.tar.bz2
rails-20e2140ce7cd6ece8769fb09a7e615e961446b02.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activerecord/lib/active_record/serializers/xml_serializer.rb')
-rw-r--r--activerecord/lib/active_record/serializers/xml_serializer.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb
index 4eaf9531e2..c3811caa53 100644
--- a/activerecord/lib/active_record/serializers/xml_serializer.rb
+++ b/activerecord/lib/active_record/serializers/xml_serializer.rb
@@ -164,7 +164,9 @@ module ActiveRecord #:nodoc:
end
end
- class XmlSerializer < ActiveRecord::Serialization::Serializer #:nodoc:
+ class XmlSerializer < ActiveModel::Serializer #:nodoc:
+ include Serialization::RecordSerializer
+
def builder
@builder ||= begin
require 'builder' unless defined? ::Builder
@@ -181,7 +183,7 @@ module ActiveRecord #:nodoc:
end
def root
- root = (options[:root] || @record.class.to_s.underscore).to_s
+ root = (options[:root] || @serializable.class.to_s.underscore).to_s
reformat_name(root)
end
@@ -199,12 +201,12 @@ module ActiveRecord #:nodoc:
end
def serializable_attributes
- serializable_attribute_names.collect { |name| Attribute.new(name, @record) }
+ serializable_attribute_names.collect { |name| Attribute.new(name, @serializable) }
end
def serializable_method_attributes
Array(options[:methods]).inject([]) do |method_attributes, name|
- method_attributes << MethodAttribute.new(name.to_s, @record) if @record.respond_to?(name.to_s)
+ method_attributes << MethodAttribute.new(name.to_s, @serializable) if @serializable.respond_to?(name.to_s)
method_attributes
end
end
@@ -254,7 +256,7 @@ module ActiveRecord #:nodoc:
end
end
else
- if record = @record.send(association)
+ if record = @serializable.send(association)
record.to_xml(opts.merge(:root => association))
end
end