diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-07-06 10:29:05 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-07-06 10:29:05 -0300 |
commit | fb46d00fdfa724dc0c252a46ec13c4ee4cda4708 (patch) | |
tree | 0ba1f359515d1054a286d754992db0fa70dec9c8 /activerecord/lib/active_record/serializers/xml_serializer.rb | |
parent | 6d4b6a247ef4119f9657293c552ae71459a3665a (diff) | |
parent | 783db25e0c640c1588732967a87d65c10fddc08e (diff) | |
download | rails-fb46d00fdfa724dc0c252a46ec13c4ee4cda4708.tar.gz rails-fb46d00fdfa724dc0c252a46ec13c4ee4cda4708.tar.bz2 rails-fb46d00fdfa724dc0c252a46ec13c4ee4cda4708.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/lib/active_record/serializers/xml_serializer.rb')
-rw-r--r-- | activerecord/lib/active_record/serializers/xml_serializer.rb | 12 |
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 |