Permalink
Browse files

Added XML serialization

  • Loading branch information...
1 parent 16f842f commit 28c1d671abf9718c51c67e59dd9dead786d93b42 @bkeepers bkeepers committed Sep 26, 2010
Showing with 7 additions and 1 deletion.
  1. +6 −0 lib/mongo_mapper/plugins/serialization.rb
  2. +1 −1 test/unit/test_serialization.rb
@@ -1,12 +1,14 @@
# encoding: UTF-8
require 'active_model/serializers/json'
+require 'active_model/serializers/xml'
module MongoMapper
module Plugins
module Serialization
def self.configure(model)
model.class_eval do
include ::ActiveModel::Serializers::JSON
+ include ::ActiveModel::Serializers::Xml
self.include_root_in_json = false
end
end
@@ -27,6 +29,10 @@ module ClassMethods
def from_json(json)
self.new.from_json(json)
end
+
+ def from_xml(xml)
+ self.new.from_xml(xml)
+ end
end
end
@@ -19,7 +19,7 @@ def setup
)
end
- [:json].each do |format|
+ [:json, :xml].each do |format|
context format do
should "be reversable" do
serialized = @instance.send("to_#{format}")

0 comments on commit 28c1d67

Please sign in to comment.