From: David Lutterkort <[email protected]>
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