You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/09/10 11:21:47 UTC
[2/2] git commit: CIMI: Prevent re-using Struct constants in models
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 <mf...@redhat.com>
Authored: Thu Sep 6 14:37:57 2012 +0200
Committer: Michal fojtik <mf...@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