Return-Path: Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: (qmail 35097 invoked from network); 29 Mar 2011 23:36:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Mar 2011 23:36:23 -0000 Received: (qmail 58877 invoked by uid 500); 29 Mar 2011 23:36:23 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 58842 invoked by uid 500); 29 Mar 2011 23:36:23 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 58834 invoked by uid 99); 29 Mar 2011 23:36:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2011 23:36:23 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lutter@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2011 23:36:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2TNZulv010132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Mar 2011 19:35:56 -0400 Received: from avon.watzmann.net (ovpn-113-147.phx2.redhat.com [10.3.113.147]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2TNZtAI032277 for ; Tue, 29 Mar 2011 19:35:55 -0400 From: lutter@redhat.com To: deltacloud-dev@incubator.apache.org Subject: [PATCH 1/3] Rabbit: add notion of a 'global' collection Date: Tue, 29 Mar 2011 16:35:50 -0700 Message-Id: <1301441752-15265-2-git-send-email-lutter@redhat.com> In-Reply-To: <1301441752-15265-1-git-send-email-lutter@redhat.com> References: <1301441752-15265-1-git-send-email-lutter@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 From: David Lutterkort Global collections are supported by every driver --- server/lib/sinatra/rabbit.rb | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb index a465ed6..8be2b8b 100644 --- a/server/lib/sinatra/rabbit.rb +++ b/server/lib/sinatra/rabbit.rb @@ -179,6 +179,7 @@ module Sinatra @name = name @description = "" @operations = {} + @global = false instance_eval(&block) if block_given? generate_documentation generate_head @@ -193,6 +194,18 @@ module Sinatra @description = text end + # Mark this collection as global, i.e. independent of any specific + # driver + def global! + @global = true + end + + # Return +true+ if this collection is global, i.e. independent of any + # specific driver + def global? + @global + end + def generate_head current_collection = self ::Sinatra::Application.head("/api/#{name}") do @@ -261,7 +274,7 @@ module Sinatra end def check_supported(driver) - unless driver.has_collection?(@name) + unless global? || driver.has_collection?(@name) raise UnsupportedCollectionException, "Collection #{@name} not supported by this driver" end @@ -301,7 +314,7 @@ module Sinatra def entry_points collections.values.select { |coll| - driver.has_collection?(coll.name) + coll.global? || driver.has_collection?(coll.name) }.inject([]) do |m, coll| url = url_for coll.operations[:index].path, :full m << [ coll.name, url ] -- 1.7.4