deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [3/3] git commit: CIMI: move deep cloning to CIMI::Model::Schema#deep_clone
Date Wed, 06 Feb 2013 22:40:26 GMT
Updated Branches:
  refs/heads/master 227a4eba4 -> 06f042dcd


CIMI: move deep cloning to CIMI::Model::Schema#deep_clone


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

Branch: refs/heads/master
Commit: 06f042dcd8fc010c56b8ce53408a385cc19ebcb2
Parents: 7e83377
Author: David Lutterkort <lutter@redhat.com>
Authored: Thu Dec 13 11:11:04 2012 -0800
Committer: David Lutterkort <lutter@redhat.com>
Committed: Wed Feb 6 14:39:57 2013 -0800

----------------------------------------------------------------------
 server/lib/cimi/models/resource.rb |    2 +-
 server/lib/cimi/models/schema.rb   |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/06f042dc/server/lib/cimi/models/resource.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/resource.rb b/server/lib/cimi/models/resource.rb
index 0586538..3271c5e 100644
--- a/server/lib/cimi/models/resource.rb
+++ b/server/lib/cimi/models/resource.rb
@@ -56,7 +56,7 @@ module CIMI
 
         def clone_base_schema
           @schema_duped = true
-          @schema = Marshal::load(Marshal.dump(superclass.base_schema))
+          @schema = superclass.base_schema.deep_clone
         end
 
         def base_schema_cloned?

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/06f042dc/server/lib/cimi/models/schema.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/schema.rb b/server/lib/cimi/models/schema.rb
index 4026c69..298075b 100644
--- a/server/lib/cimi/models/schema.rb
+++ b/server/lib/cimi/models/schema.rb
@@ -91,6 +91,9 @@ class CIMI::Model::Schema
     def initialize(name, opts, &block)
       content = opts[:content]
       super(name, opts)
+      if opts[:class]
+        opts[:schema] = opts[:class].schema
+      end
       if opts[:schema]
         if block_given?
           raise "Cannot provide :schema option and a block"
@@ -280,6 +283,10 @@ class CIMI::Model::Schema
     @attributes = []
   end
 
+  def deep_clone
+    Marshal::load(Marshal.dump(self))
+  end
+
   def collections
     @attributes.select { |a| a.is_a?(Collection) }
   end


Mime
View raw message