deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [2/3] git commit: CIMI base model: add 'parse' method
Date Thu, 30 Aug 2012 18:44:41 GMT
CIMI base model: add 'parse' method

Dispatch between from_xml and from_json depending on content type


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/e2c80561
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/e2c80561
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/e2c80561

Branch: refs/heads/master
Commit: e2c80561ff89822dee3386c7b4af99e0e9ba4baa
Parents: 05cdb49
Author: David Lutterkort <lutter@redhat.com>
Authored: Tue Aug 21 13:20:57 2012 -0700
Committer: David Lutterkort <lutter@redhat.com>
Committed: Thu Aug 30 11:31:59 2012 -0700

----------------------------------------------------------------------
 server/lib/cimi/models/base.rb |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e2c80561/server/lib/cimi/models/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/base.rb b/server/lib/cimi/models/base.rb
index 9e4b286..b375ce0 100644
--- a/server/lib/cimi/models/base.rb
+++ b/server/lib/cimi/models/base.rb
@@ -168,6 +168,16 @@ class CIMI::Model::Base
     model
   end
 
+  def self.parse(text, content_type)
+    if content_type == "application/xml"
+      from_xml(text)
+    elsif content_type == "application/json"
+      from_json(text)
+    else
+      raise "Can not parse content type #{content_type}"
+    end
+  end
+
   #
   # Serialize
   #


Mime
View raw message