You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2011/03/31 23:20:26 UTC
svn commit: r1087441 -
/incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb
Author: lutter
Date: Thu Mar 31 21:20:26 2011
New Revision: 1087441
URL: http://svn.apache.org/viewvc?rev=1087441&view=rev
Log:
Rabbit: add notion of a 'global' collection
Global collections are supported by every driver
Modified:
incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb
Modified: incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb?rev=1087441&r1=1087440&r2=1087441&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb (original)
+++ incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb Thu Mar 31 21:20:26 2011
@@ -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 ]