Module: StandardAPI::RouteHelpers
- Defined in:
- lib/standard_api/route_helpers.rb
Instance Method Summary collapse
-
#standard_resource(*resource, &block) ⇒ Object
StandardAPI wrapper for ActionDispatch::Routing::Mapper::Resources#resource.
-
#standard_resources(*resources, &block) ⇒ Object
StandardAPI wrapper for ActionDispatch::Routing::Mapper::Resources#resources.
Instance Method Details
#standard_resource(*resource, &block) ⇒ Object
StandardAPI wrapper for ActionDispatch::Routing::Mapper::Resources#resource
Includes the following routes
GET /schema
GET /calculate
For example:
standard_resource :account
is equivilent to:
resource :account do
get :schema, on: :collection
get :calculate, on: :collection
end
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/standard_api/route_helpers.rb', line 50 def standard_resource(*resource, &block) = resource..dup resource(*resource, ) do get :schema, on: :collection get :calculate, on: :collection delete ':relationship/:resource_id' => :remove_resource, on: :member post ':relationship/:resource_id' => :add_resource, on: :member block.call if block end end |
#standard_resources(*resources, &block) ⇒ Object
StandardAPI wrapper for ActionDispatch::Routing::Mapper::Resources#resources
Includes the following routes
GET /schema
GET /calculate
For example
standard_resources :views
is equivilent to:
resources :api_keys do
get :schema, on: :collection
get :calculate, on: :collection
end
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/standard_api/route_helpers.rb', line 21 def standard_resources(*resources, &block) = resources..dup resources(*resources, ) do get :schema, on: :collection get :calculate, on: :collection delete ':relationship/:resource_id' => :remove_resource, on: :member post ':relationship/:resource_id' => :add_resource, on: :member block.call if block end end |