Class Grape::API
In: lib/grape.rb
lib/grape/api.rb
lib/grape/api/helpers.rb
lib/grape/api/instance.rb
lib/grape/validations/validators/coerce.rb
Parent: Object

The API class is the primary entry point for creating Grape APIs. Users should subclass this class in order to build an API.

Methods

Classes and Modules

Module Grape::API::Helpers
Class Grape::API::Instance

Constants

NON_OVERRIDABLE = (Class.new.methods + %i[call call!]).freeze   Class methods that we want to call on the API rather than on the API object
Boolean = Virtus::Attribute::Boolean

Attributes

base_instance  [RW] 
instances  [RW] 

Public Class methods

This is the interface point between Rack and Grape; it accepts a request from Rack and ultimately returns an array of three values: the status, the headers, and the body. See [the rack specification] (www.rubydoc.info/github/rack/rack/master/file/SPEC) for more. NOTE: This will only be called on an API directly mounted on RACK

Alleviates problems with autoloading by tring to search for the constant

When inherited, will create a list of all instances (times the API was mounted) It will listen to the setup required to mount that endpoint, and replicate it on any new instance

Initialize the instance variables on the remountable class, and the base_instance an instance that will be used to create the set up but will not be mounted

Allows an API to itself be inheritable:

The remountable class can have a configuration hash to provide some dynamic class-level variables. For instance, a descripcion could be done using: `desc configuration[:description]` if it may vary depending on where the endpoint is mounted. Use with care, if you find yourself using configuration too much, you may actually want to provide a new API rather than remount it.

Rather than initializing an object of type Grape::API, create an object of type Instance

Redefines all methods so that are forwarded to add_setup and be recorded

Replays the set up to produce an API as defined in this class, can be called on classes that inherit from Grape::API

[Validate]