Permalink
Browse files

Step 5: Rendering from templates

  • Loading branch information...
1 parent d08f1b4 commit a5da103b4bef3995490aeaa7b75e7c6d86f9506d Carl Lerche committed Aug 27, 2009
Showing with 8 additions and 1 deletion.
  1. +8 −1 sinatrails.rb
View
@@ -89,10 +89,17 @@ def _set_sessions(value)
end
end
+ # Halt can be implemented by simply throwing.
+ def halt(body = "")
+ throw(:halt, body)
+ end
+
# The default behavior is that the action's return value
# is the response body.
def process_action(*)
- self.response_body = super
+ # We are now catching the throw that could be sent
+ # when halting from a before callback.
+ self.response_body = catch(:halt) { super }
end
end
end

0 comments on commit a5da103

Please sign in to comment.