vendor/bundle/ruby/1.8/gems/sinatra-1.2.8/lib/sinatra/base.rb
# Run the block with 'throw :halt' support and apply result to the response.
Run the block with 'throw :halt' support and apply result to the response.
Run the block with ' throw : halt ' support and apply result to the response .
def invoke
      res = catch(:halt) { yield }
      return if res.nil?
      case
      when res.respond_to?(:to_str)
        @response.body = [res]
      when Array === res
        if Fixnum === res.first
          if res.length == 3
            @response.status, headers, body = res
            @response.body = body if body
            headers.each { |k, v| @response.headers[k] = v } if headers
          elsif res.length == 2
            @response.status = res.first
            @response.body   = res.last
          else
            raise TypeError, "#{res.inspect} not supported"
          end
        else
          @response.body = res
        end
      when res.respond_to?(:each)
        @response.body = res
      when (100..599) === res
        @response.status = res
      end
      res
    end
def invoke res = catch ( :halt ) { yield } return if res . nil? case when res . respond_to? ( :to_str ) @response . body = [ res ] when Array === res if Fixnum === res . first if res . length == 3 @response . status , headers , body = res @response . body = body if body headers . each { | k , v | @response . headers [ k ] = v } if headers elsif res . length == 2 @response . status = res . first @response . body = res . last else raise TypeError , "#{res.inspect} not supported" end else @response . body = res end when res . respond_to? ( :each ) @response . body = res when ( 100 .. 599 ) === res @response . status = res end res end
Run the block with 'throw :halt' support and apply result to the response.
Run the block with ' throw : halt ' support and apply result to the response .