Module: Sinatra

Defined in:
lib/sinatra/base.rb,
lib/sinatra/main.rb,
lib/sinatra/version.rb,
lib/sinatra/show_exceptions.rb,
lib/sinatra/indifferent_hash.rb

Defined Under Namespace

Modules: Delegator, Helpers, Templates Classes: Application, BadRequest, Base, CommonLogger, ExtendedRack, IndifferentHash, NotFound, Request, Response, ShowExceptions, Wrapper

Constant Summary collapse

ParamsConfig =
{}
VERSION =
'2.1.0'

Class Method Summary collapse

Class Method Details

.helpers(*extensions, &block) ⇒ Object

Include the helper modules provided in Sinatra's request context.



2012
2013
2014
# File 'lib/sinatra/base.rb', line 2012

def self.helpers(*extensions, &block)
  Delegator.target.helpers(*extensions, &block)
end

.new(base = Base, &block) ⇒ Object

Create a new Sinatra application; the block is evaluated in the class scope.



2000
2001
2002
2003
2004
# File 'lib/sinatra/base.rb', line 2000

def self.new(base = Base, &block)
  base = Class.new(base)
  base.class_eval(&block) if block_given?
  base
end

.register(*extensions, &block) ⇒ Object

Extend the top-level DSL with the modules provided.



2007
2008
2009
# File 'lib/sinatra/base.rb', line 2007

def self.register(*extensions, &block)
  Delegator.target.register(*extensions, &block)
end

.use(*args, &block) ⇒ Object

Use the middleware for classic applications.



2017
2018
2019
# File 'lib/sinatra/base.rb', line 2017

def self.use(*args, &block)
  Delegator.target.use(*args, &block)
end