class Sinatra::Rabbit::BaseCollection
Public Class Methods
Source
# File lib/sinatra/rabbit/base_collection.rb, line 51 def self.collection_class(name, parent_class=nil) if base_module = Rabbit::configuration[:base_module] begin base_module = base_module.const_get 'Rabbit' rescue NameError base_module = base_module.const_set('Rabbit', Module.new) end else base_module = Sinatra::Rabbit end klass = parent_class || base_module begin yield k = klass.const_get(name.to_s.camelize + 'Collection') rescue NameError yield k = klass.const_set(name.to_s.camelize + 'Collection', Class.new(Collection)) end return k end
Source
# File lib/sinatra/rabbit/base_collection.rb, line 46 def self.http_method_for(operation_name) o = Sinatra::Rabbit::STANDARD_OPERATIONS[operation_name] (o && o[:method]) ? o[:method] : :get end
Source
# File lib/sinatra/rabbit/base_collection.rb, line 70 def self.root_path Sinatra::Rabbit.configuration[:root_path] || '/' end
Source
# File lib/sinatra/rabbit/base_collection.rb, line 24 def self.route_for(collection, operation_name=nil, member=:member) unless operation_name.nil? o = Sinatra::Rabbit::STANDARD_OPERATIONS[operation_name] if o o = o.clone o[:member] = false if member == :no_member o[:collection] = true if member == :no_id if member == :no_id_and_member or member == :docs o[:collection] = true o[:member] = true end end operation_path = (o && o[:member]) ? operation_name.to_s : nil operation_path = operation_name.to_s unless o id_param = (o && o[:collection]) ? nil : (member.kind_of?(Hash) ? member[:id_name] : ":id") id_param.gsub!(':', '') if id_param and member == :docs [route_for(collection), id_param, operation_path].compact.join('/') else collection.to_s end end