Method: Gin::Controller#invoke

Defined in:
lib/gin/controller.rb

#invokeObject

Taken from Sinatra.

Run the block with ‘throw :halt’ support and apply result to the response.



926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/gin/controller.rb', line 926

def invoke
  res = catch(:halt) { yield }
  res = [res] if Fixnum === res || String === res
  if Array === res && Fixnum === res.first
    res = res.dup
    status(res.shift)
    body(res.pop)
    headers(*res)
  elsif res.respond_to? :each
    body res
  end
  nil # avoid double setting the same response tuple twice
end