deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 03/10] CIMI: remove obsolete attributes from Collection
Date Thu, 08 Nov 2012 04:05:29 GMT
From: David Lutterkort <lutter@redhat.com>

Introduces new CIMI::Model::Resource which has all the basic plumbing of
Base, without any predefined attributes
---
 server/lib/cimi/models/base.rb       |   18 ++++++++++--------
 server/lib/cimi/models/collection.rb |    3 ++-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/server/lib/cimi/models/base.rb b/server/lib/cimi/models/base.rb
index 9217939..668fedb 100644
--- a/server/lib/cimi/models/base.rb
+++ b/server/lib/cimi/models/base.rb
@@ -91,7 +91,7 @@ module CIMI::Model
 
 end
 
-class CIMI::Model::Base
+class CIMI::Model::Resource
 
   #
   # We keep the values of the attributes in a hash
@@ -245,13 +245,6 @@ class CIMI::Model::Base
     self.class.to_xml(self)
   end
 
-  #
-  # Common attributes for all resources
-  #
-  text :id, :name, :description, :created
-
-  hash :property
-
   def filter_by(filter_opts)
     return self if filter_opts.nil?
     return filter_attributes(filter_opts.split(',').map{ |a| a.intern }) if filter_opts.include?
','
@@ -284,3 +277,12 @@ class CIMI::Model::Base
     self.class.new(attr => self.send(attr)[filter])
   end
 end
+
+class CIMI::Model::Base < CIMI::Model::Resource
+  #
+  # Common attributes for all resources
+  #
+  text :id, :name, :description, :created
+
+  hash :property
+end
diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
index db08047..2373359 100644
--- a/server/lib/cimi/models/collection.rb
+++ b/server/lib/cimi/models/collection.rb
@@ -14,7 +14,7 @@
 # under the License.
 
 module CIMI::Model
-  class Collection < Base
+  class Collection < Resource
 
     class << self
       attr_accessor :entry_name, :embedded
@@ -75,6 +75,7 @@ module CIMI::Model
       coll_class.embedded = opts[:embedded]
       entry_schema = model_class.schema
       coll_class.instance_eval do
+        text :id
         text :count
         scalar :href if opts[:embedded]
         array self.entry_name, :schema => entry_schema, :xml_name => model_name
-- 
1.7.7.6


Mime
View raw message