lotus/controller — pull request #8 by sidonath (2014-04-20 20:02:24+00:00)
Title: Replace `#throw` override with `#halt` method

Redefining `Kernel#throw` is surprising since it prevents developers from using `catch`/`throw` pattern inside actions. Instead, we provide `#halt` method that accepts a status code (and does the `throw` internally).

I haven't fixed/checked the documentation in README or other places in code, but if you agree this change is beneficial I'll amend it to this PR.

Moreover, it feels like it would be useful to change `halt` so it doesn't require any arguments. In this case it would simply abort the action execution and wouldn't change the response status or body. This allows developers to abort actions from helper methods. Consider this example:

```ruby
class Create
include Lotus::Action

def call(params)
article = validate(params)
ArticleRepository.persist(article)
redirect_to '/'
end

def validate(params)
article = Article.new
validator = ArticleValidator.new(article)
if validator.valid?
return article
end

# abort the action when data is invalid (thus rendering `Create` view)
halt
end
end
```

Since the behavior of `halt` with and without arguments would be different, maybe it would make more sense to define a new method (`abort`?). Let me know what you think about this and if I should start a new PR or just add it to this one.