deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/2] git commit: CIMI: Prevent re-using Struct constants in models
Date Mon, 10 Sep 2012 09:21:47 GMT
CIMI: Prevent re-using Struct constants in models


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

Branch: refs/heads/master
Commit: 66c55d16ca44d058c4360e1ecd728eda8eeb8641
Parents: cfe3041
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Sep 6 14:37:57 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Sep 10 11:22:21 2012 +0200

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


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/66c55d16/server/lib/cimi/models/schema.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/schema.rb b/server/lib/cimi/models/schema.rb
index 088e111..4aa512a 100644
--- a/server/lib/cimi/models/schema.rb
+++ b/server/lib/cimi/models/schema.rb
@@ -139,12 +139,8 @@ class CIMI::Model::Schema
     private
     def struct
       cname = "CIMI_#{json_name.upcase_first}"
-      if ::Struct.const_defined?(cname)
-        ::Struct.const_get(cname)
-      else
-        ::Struct.new("CIMI_#{json_name.upcase_first}",
-                     *@schema.attribute_names)
-      end
+      ::Struct.send(:remove_const, cname) if ::Struct.const_defined?(cname)
+      @struct_class ||= ::Struct.new(cname, *@schema.attribute_names)
     end
   end
 


Mime
View raw message