Parent

Files

Sinatra::Helpers::Stream::Base

Base class for all Sinatra applications and middleware.

Attributes

app[RW]
env[RW]
params[RW]
request[RW]
response[RW]
template_cache[R]

Public Class Methods

new(app = nil) click to toggle source
# File lib/sinatra/base.rb, line 877
def initialize(app = nil)
  super()
  @app = app
  @template_cache = Tilt::Cache.new
  yield self if block_given?
end
Also aliased as: new!
settings() click to toggle source

Access settings defined with Base.set.

# File lib/sinatra/base.rb, line 913
def self.settings
  self
end

Public Instance Methods

call(env) click to toggle source

Rack call interface.

# File lib/sinatra/base.rb, line 885
def call(env)
  dup.call!(env)
end
forward() click to toggle source

Forward the request to the downstream app – middleware only.

# File lib/sinatra/base.rb, line 943
def forward
  fail "downstream app not set" unless @app.respond_to? :call
  status, headers, body = @app.call env
  @response.status = status
  @response.body = body
  @response.headers.merge! headers
  nil
end
halt(*response) click to toggle source

Exit the current block, halts any further processing of the request, and returns the specified response.

# File lib/sinatra/base.rb, line 930
def halt(*response)
  response = response.first if response.length == 1
  throw :halt, response
end
options() click to toggle source
# File lib/sinatra/base.rb, line 922
def options
  warn "Sinatra::Base#options is deprecated and will be removed, "          "use #settings instead."
  settings
end
pass(&block) click to toggle source

Pass control to the next matching route. If there are no more matching routes, Sinatra will return a 404 response.

# File lib/sinatra/base.rb, line 938
def pass(&block)
  throw :pass, block
end
settings() click to toggle source

Access settings defined with Base.set.

# File lib/sinatra/base.rb, line 918
def settings
  self.class.settings
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.