Class: Smooth::Endpoint
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Smooth::Endpoint
- Defined in:
- lib/smooth/endpoint.rb
Class Method Summary collapse
Class Method Details
.interface_for(model_class, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/smooth/endpoint.rb', line 8 def self.interface_for(model_class, ={}) collection = model_class.collection resource_name = .fetch(:resource_name, collection.namespace) prefix = .fetch(:prefix, "/smooth/api/v1") get "#{ prefix }/#{ resource_name }" do json collection.query(params) end get "#{ prefix }/#{ resource_name }/:id" do json collection.show(params[:id]) end end |