Skip to content
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

Refactor actions system #85

Merged
merged 5 commits into from
Jun 7, 2018
Merged

Refactor actions system #85

merged 5 commits into from
Jun 7, 2018

Conversation

printercu
Copy link
Member

@printercu printercu commented May 28, 2018

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:

  1. explicitly call command :cmd_name or command 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 requires self.included to mark command actions in target controller).
  2. add prefix/suffix to command when mapping it to method name: /cmd_name => _cmd_name or cmd_name!. It would be much better if ruby supported def /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

@printercu printercu merged commit 64d0068 into master Jun 7, 2018
@printercu printercu deleted the commands branch June 7, 2018 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to disable run callback query methods?
1 participant