Module: Roy::Halt::InstanceMethods

Defined in:
lib/roy/halt.rb

Instance Method Summary collapse

Instance Method Details

#halt(code, message = nil) ⇒ Integer, String

Break from the current catch(:halt) block

Parameters:

  • code (Integer)

    the response status code.

  • message (String) (defaults to: nil)

    the response body.

Returns:

  • (Integer, String)

    the status and the given message or a default one.



34
35
36
# File 'lib/roy/halt.rb', line 34

def halt(code, message=nil)
  throw :halt, [code, message || Rack::Utils::HTTP_STATUS_CODES[code]]
end