deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 3/3] CIMI: move deep cloning to CIMI::Model::Schema#deep_clone
Date Wed, 06 Feb 2013 00:11:33 GMT
From: David Lutterkort <lutter@redhat.com>

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

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?
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
-- 
1.8.1


Mime
View raw message