module Sinatra::Rabbit::DSL
Public Class Methods
<<(c)
click to toggle source
# File lib/sinatra/rabbit/dsl.rb, line 54 def self.<<(c) register_collection(c) end
register_collection(c, &block)
click to toggle source
# File lib/sinatra/rabbit/dsl.rb, line 49 def self.register_collection(c, &block) @collections ||= [] @collections << c end
Public Instance Methods
[](collection)
click to toggle source
# File lib/sinatra/rabbit/dsl.rb, line 58 def [](collection) collections.find { |c| c.collection_name == collection } end
collection(name, &block)
click to toggle source
Create DSL
wrapper for creating a new collection
Example:
collection :images do description "Images collection" operation :index do ... end end
# File lib/sinatra/rabbit/dsl.rb, line 32 def collection(name, &block) return self[name] unless block_given? current_collection = BaseCollection.collection_class(name) do |c| c.base_class = self c.generate(name, &block) end collections << current_collection DSL << current_collection use current_collection end
collections()
click to toggle source
Return all defined collections
# File lib/sinatra/rabbit/dsl.rb, line 45 def collections @collections ||= [] end