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

Handle commands with spaces when using Controller #144

Merged
merged 3 commits into from
Jun 8, 2017
Merged

Handle commands with spaces when using Controller #144

merged 3 commits into from
Jun 8, 2017

Conversation

chuckremes
Copy link
Collaborator

I missed a use-case when first designing the MVC classes. Sometimes people design commands like this:

class Agent < SlackRubyBot::Bot
  command 'run some command' do |*args|
    ...
  end
end

If someone sent a command with spaces to the controller it would fail to match any known method.

So, the Controller class was augmented to support this. Any method names that contain embedded underscores '_' will now generate a command matcher with spaces. When that command matches a route and we try to call the corresponding controller method, the command is downcased and converted to a method_name_with_spaces.

@@ -55,10 +55,11 @@ def register_controller(controller)

methods.each do |meth_name|
next if meth_name[0] == '_'
method_name = convert_method_name(meth_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly poor choice of variable name, method_name vs. meth_name, just make it m.

@dblock dblock merged commit 612890b into slack-ruby:master Jun 8, 2017
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.

None yet

2 participants