Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use bang-methods as action names for commands.
I always felt that something was wrong with mapping command to action: there was workaround for name conflicts, specially crafted update could call other actions with unexpected arguments, there was no way to distinct actions for commands from other actions, etc. Developers have to keep all this in mind and use workarounds.
I saw two ways to solve it:
command :cmd_name
orcommand def cmd_name(*)
to mark action as command. I don't like this way because it's opposite to what i like in ActionController, and module with actions can not simply included (it requiresself.included
to mark command actions in target controller)./cmd_name => _cmd_name or cmd_name!
. It would be much better if ruby supporteddef /start(*)
, but it's not the case. I was thinking about any textual prefix/suffix that would essentially fit most of commands. But finally I decided to proceed with bang-methods, because they are supported by ruby syntax.Drop
.context_handler
, and make MessageContext work like.context_to_action!
is enabled by default.After changing commands to be mapped to bang-methods, name conflicts get less possible. So
context_handler
appears redundant.Fixes #81