Module: Sinatra::Rabbit

Defined in:
lib/sinatra/rabbit.rb

Defined Under Namespace

Classes: Collection, DuplicateCollectionException, DuplicateOperationException, DuplicateParamException, Operation

Instance Method Summary collapse

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.



204
205
206
207
208
209
210
# File 'lib/sinatra/rabbit.rb', line 204

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
end

#collectionsObject



195
196
197
# File 'lib/sinatra/rabbit.rb', line 195

def collections
  @collections ||= {}
end