You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2012/08/30 20:44:41 UTC
[2/3] git commit: CIMI base model: add 'parse' method
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 <lu...@redhat.com>
Authored: Tue Aug 21 13:20:57 2012 -0700
Committer: David Lutterkort <lu...@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
#