-
-
Notifications
You must be signed in to change notification settings - Fork 116
Do not explicitly require Controller#call method #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@gammons Thanks for this PR. What's the use case? I mean, if you don't need to implement |
@gammons RE test: class ActionWithoutCall
include Lotus::Action
end
it "doesn't require #call implementation" do
action = ActionWithoutCall.new
code, _, _ = action.call({})
code.must_equal(200)
end |
@jodosha FWIW I find this useful as well since sometimes all logic can happen in callbacks or there's no logic at all (e.g. rendering a dumb template) |
@jodosha What @sidonath said ;) I have a landing page that had no need for any controller logic. Also, thank you for that recommendation for a good test. The action was not raising an error, but rather it was throwing a 500. So I was able to validate my change with a spec, which I added above. |
@gammons @sidonath I've evaluated this issue, if we allow to omit it there are two downsides:
|
The empty method definition could be easily extracted out to a mixing in your application, right? |
I found it slightly odd that I needed to always write a
.call
method in my controllers when that method was empty. So instead I decided to check for the existence of the super method in the parent class first.