Class: Rack::API

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rack/api.rb,
lib/rack/api/runner.rb,
lib/rack/api/version.rb,
lib/rack/api/response.rb,
lib/rack/api/formatter.rb,
lib/rack/api/controller.rb,
lib/rack/api/middleware.rb,
lib/rack/api/formatter/base.rb,
lib/rack/api/middleware/ssl.rb,
lib/rack/api/formatter/jsonp.rb,
lib/rack/api/middleware/limit.rb,
lib/rack/api/middleware/format.rb

Defined Under Namespace

Modules: Formatter, Middleware, Version Classes: Controller, Response, Runner

Class Method Summary collapse

Class Method Details

.app(&block) ⇒ Object

A shortcut for defining new APIs. Instead of creating a class that inherits from Rack::API, you can simply pass a block to the Rack::API.app method.

Rack::API.app do
  # define your API
end


33
34
35
36
# File 'lib/rack/api.rb', line 33

def self.app(&block)
  runner.instance_eval(&block)
  runner
end

.call(env) ⇒ Object

Required by Rack.



46
47
48
# File 'lib/rack/api.rb', line 46

def self.call(env) # :nodoc:
  runner.call(env)
end

.reset!Object

Reset all API definitions while using the Rack::API.app method.



40
41
42
# File 'lib/rack/api.rb', line 40

def self.reset!
  @runner = nil
end