Class Sinatra::Base
In: lib/sinatra/base.rb
Parent: Object

Methods

call   call   call!   configure   development?   halt   new   options   pass   production?   run!   test?   use  

Included Modules

Rack::Utils Helpers Templates

Attributes

app  [RW] 
conditions  [RW] 
env  [RW] 
errors  [RW] 
filters  [RW] 
middleware  [RW] 
params  [RW] 
request  [RW] 
response  [RW] 
routes  [RW] 
templates  [RW] 

Public Class methods

[Source]

     # File lib/sinatra/base.rb, line 669
669:       def call(env)
670:         construct_middleware if @callsite.nil?
671:         @callsite.call(env)
672:       end

[Source]

     # File lib/sinatra/base.rb, line 643
643:       def configure(*envs, &block)
644:         yield if envs.empty? || envs.include?(environment.to_sym)
645:       end

[Source]

     # File lib/sinatra/base.rb, line 639
639:       def development? ; environment == :development ; end

[Source]

     # File lib/sinatra/base.rb, line 298
298:     def initialize(app=nil)
299:       @app = app
300:       yield self if block_given?
301:     end

[Source]

     # File lib/sinatra/base.rb, line 641
641:       def production? ; environment == :production ; end

[Source]

     # File lib/sinatra/base.rb, line 652
652:       def run!(options={})
653:         set options
654:         handler = detect_rack_handler
655:         handler_name = handler.name.gsub(/.*::/, '')
656:         puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
657:           "on #{port} for #{environment} with backup from #{handler_name}"
658:         handler.run self, :Host => host, :Port => port do |server|
659:           trap(:INT) do
660:             ## Use thins' hard #stop! if available, otherwise just #stop
661:             server.respond_to?(:stop!) ? server.stop! : server.stop
662:             puts "\n== Sinatra has ended his set (crowd applauds)"
663:           end
664:         end
665:       rescue Errno::EADDRINUSE => e
666:         puts "== Someone is already performing on port #{port}!"
667:       end

[Source]

     # File lib/sinatra/base.rb, line 640
640:       def test? ; environment == :test ; end

[Source]

     # File lib/sinatra/base.rb, line 647
647:       def use(middleware, *args, &block)
648:         reset_middleware
649:         @middleware << [middleware, args, block]
650:       end

Public Instance methods

[Source]

     # File lib/sinatra/base.rb, line 303
303:     def call(env)
304:       dup.call!(env)
305:     end

[Source]

     # File lib/sinatra/base.rb, line 309
309:     def call!(env)
310:       @env      = env
311:       @request  = Request.new(env)
312:       @response = Response.new
313:       @params   = nil
314: 
315:       invoke { dispatch! }
316:       invoke { error_block!(response.status) }
317: 
318:       @response.body = [] if @env['REQUEST_METHOD'] == 'HEAD'
319:       @response.finish
320:     end

[Source]

     # File lib/sinatra/base.rb, line 326
326:     def halt(*response)
327:       response = response.first if response.length == 1
328:       throw :halt, response
329:     end

[Source]

     # File lib/sinatra/base.rb, line 322
322:     def options
323:       self.class
324:     end

[Source]

     # File lib/sinatra/base.rb, line 331
331:     def pass
332:       throw :pass
333:     end

[Validate]