deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Core: Added url_for helpers for Rabbit subcollections (DTACLOUD-526)
Date Thu, 04 Apr 2013 14:57:30 GMT
From: Michal Fojtik <mfojtik@redhat.com>

This patch add URL helpers for all Rabbit subcollections, like:

system_volumes(:id => system_id)
=>  "http://localhost:3001/cimi/systems/system_id/volumes"

system_volumes(:id => system_id, :ent_id => volume_id)
=>  "http://localhost:3001/cimi/systems/system_id/volumes/volume_id"

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/helpers/rabbit_helper.rb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/server/lib/deltacloud/helpers/rabbit_helper.rb b/server/lib/deltacloud/helpers/rabbit_helper.rb
index a8ae4f5..b249dc6 100644
--- a/server/lib/deltacloud/helpers/rabbit_helper.rb
+++ b/server/lib/deltacloud/helpers/rabbit_helper.rb
@@ -45,6 +45,7 @@ module Sinatra::Rabbit
       c.operations.each do |operation|
         URLHelper.instance_eval(&generate_url_helper_for(c, operation)[0])
       end
+      URLFor(c.collections)
     end
     URLHelper
   end
@@ -53,6 +54,10 @@ module Sinatra::Rabbit
     operation_name = operation.operation_name.to_s
     collection_name = collection.collection_name.to_s
 
+    if collection.subcollection?
+      collection_name = "#{collection.parent_collection.collection_name.to_s.singularize}_#{collection_name}"
+    end
+
     # Construct OPERATION_COLLECTION_URL helper
     # The :index and :create operation does not get any prefix
     #
-- 
1.8.1.4


Mime
View raw message