module StandardAPI::RouteHelpers

Public Instance Methods

standard_resource(*resource, &block) click to toggle source

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
# File lib/standard_api/route_helpers.rb, line 50
def standard_resource(*resource, &block)
  options = resource.extract_options!.dup

  resource(*resource, options) 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) click to toggle source

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
# File lib/standard_api/route_helpers.rb, line 21
def standard_resources(*resources, &block)
  options = resources.extract_options!.dup

  resources(*resources, options) 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