Module: Sinatra::Rabbit
- Defined in:
- lib/sinatra/rabbit.rb
Defined Under Namespace
Classes: Collection, DuplicateCollectionException, DuplicateOperationException, DuplicateParamException, Operation
Class Method Summary collapse
Instance Method Summary collapse
-
#collection(name, &block) ⇒ Object
Create a new collection.
- #collections ⇒ Object
Class Method Details
.registered(app) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/sinatra/rabbit.rb', line 214 def self.registered(app) app.register(Sinatra::RespondTo) app.helpers RabbitHelper app.class_eval { # Generate a root route for API docs get '/api/docs\/?' do respond_to do |format| format.html { haml :'docs/index' } format.xml { haml :'docs/index' } end end } end |
Instance Method Details
#collection(name, &block) ⇒ Object
Create a new collection. NAME should be the pluralized name of the collection.
Adds a helper method #name_url which returns the URL to the :index operation on this collection.
206 207 208 209 210 211 212 |
# File 'lib/sinatra/rabbit.rb', line 206 def collection(name, &block) raise DuplicateCollectionException if collections[name] #return unless driver.has_collection?(name.to_sym) collections[name] = Collection.new(name, &block) #collections[name].add_feature_params(driver.features(name)) collections[name].generate(self) end |
#collections ⇒ Object
197 198 199 |
# File 'lib/sinatra/rabbit.rb', line 197 def collections @collections ||= {} end |