You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/10/19 15:44:08 UTC

[PATCH core 2/4] CIMI: Added 'global_collection' method to Rabbit

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/sinatra/rabbit.rb |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb
index c35943b..8f34485 100644
--- a/server/lib/sinatra/rabbit.rb
+++ b/server/lib/sinatra/rabbit.rb
@@ -202,11 +202,11 @@ module Sinatra
     class Collection
       attr_reader :name, :operations, :subcollections
 
-      def initialize(name, &block)
+      def initialize(name, options={}, &block)
         @name = name
         @description = ""
         @operations, @subcollections = {}, {}
-        @global = false
+        @global = options[:global] || false
         instance_eval(&block) if block_given?
         generate_documentation
         generate_head
@@ -392,6 +392,14 @@ module Sinatra
       collections[name] = Collection.new(name, &block)
       collections[name].generate
     end
+
+    # Make sure this collection can be accessed, regardless of whether the
+    # driver supports it or not
+    def global_collection(name, &block)
+      raise DuplicateCollectionException if collections[name]
+      collections[name] = Collection.new(name, :global => true, &block)
+      collections[name].generate
+    end
   end
 
   module RabbitHelper
-- 
1.7.4.4