deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1211953 - in /deltacloud/trunk/server/lib/cimi: model/entity_metadata.rb server.rb
Date Thu, 08 Dec 2011 16:22:29 GMT
Author: marios
Date: Thu Dec  8 16:22:29 2011
New Revision: 1211953

URL: http://svn.apache.org/viewvc?rev=1211953&view=rev
Log:
Fixes to CIMI::EntityMetadata code after patch review

Modified:
    deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb
    deltacloud/trunk/server/lib/cimi/server.rb

Modified: deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb?rev=1211953&r1=1211952&r2=1211953&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb (original)
+++ deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb Thu Dec  8 16:22:29 2011
@@ -39,31 +39,25 @@ text :type_uri
     entity_metadata = []
     if id == :all
       CIMI::Model.root_entities.each do |entity|
-        entity_class = Object::const_get("CIMI").const_get("Model").const_get("#{entity.singularize}")
+        entity_class = CIMI::Model.const_get("#{entity.singularize}")
         entity_metadata << entity_class.create_entity_metadata(context) if entity_class.respond_to?("create_entity_metadata")
       end
       return entity_metadata
     else
-      entity_class = Object::const_get("CIMI").const_get("Model").const_get("#{id.camelize}")
+      entity_class = CIMI::Model.const_get("#{id.camelize}")
       entity_metadata << entity_class.create_entity_metadata(context) if entity_class.respond_to?("create_entity_metadata")
       return entity_metadata.first
     end
   end
 
   def self.metadata_from_deltacloud_features(cimi_entity, dcloud_entity, context)
-      metadata_attributes = []
       deltacloud_features = context.driver.features(dcloud_entity)
-      deltacloud_features.each do |feature|
-        metadata_attributes << attributes_from_feature(feature)
-      end
+      metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
       from_feature(cimi_entity, context, metadata_attributes)
   end
 
   def includes_attribute?(attribute)
-    self.attributes.each do |attr|
-      return true if attr[:name] == attribute
-    end
-    return false
+    self.attributes.any?{|attr| attr[:name] == attribute}
   end
 
   private

Modified: deltacloud/trunk/server/lib/cimi/server.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/server.rb?rev=1211953&r1=1211952&r2=1211953&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/server.rb (original)
+++ deltacloud/trunk/server/lib/cimi/server.rb Thu Dec  8 16:22:29 2011
@@ -429,10 +429,10 @@ global_collection :entity_metadata do
   operation :index do
     description "List all entity metadata defined for this provider"
     control do
-      entity_metadata = EntityMetadata.all(self)
+      entity_metadata = EntityMetadataCollection.default(self)
       respond_to do |format|
-        format.xml{entity_metadata.to_xml_cimi_collection(self)}
-        format.json{entity_metadata.to_json_cimi_collection(self)}
+        format.xml{entity_metadata.to_xml}
+        format.json{entity_metadata.to_json}
       end
     end
   end



Mime
View raw message