Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-13 04:17:18 +0300
committerDouwe Maan <douwe@selenight.nl>2016-08-13 04:17:18 +0300
commit5a07b760dff04660d9c7da84852c710b1fc2f786 (patch)
tree6aa67c32c6b80dcc1c7cbfe4f9f62e57edb76b3e /app/services/slash_commands
parent5d4993d62357e438b6211247278025040f3ae382 (diff)
Refactor slash command definition
Diffstat (limited to 'app/services/slash_commands')
-rw-r--r--app/services/slash_commands/interpret_service.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb
index 112bebe423a..a2b92d70f9f 100644
--- a/app/services/slash_commands/interpret_service.rb
+++ b/app/services/slash_commands/interpret_service.rb
@@ -10,20 +10,28 @@ module SlashCommands
@noteable = noteable
@updates = {}
- commands = extractor(noteable: noteable).extract_commands!(content)
- commands.each do |command, *args|
- execute_command(command, *args)
+ opts = {
+ noteable: noteable,
+ current_user: current_user,
+ project: project
+ }
+
+ content, commands = extractor.extract_commands(content, opts)
+
+ commands.each do |name, *args|
+ definition = self.class.command_definitions_by_name[name.to_sym]
+ next unless definition
+
+ definition.execute(self, opts, *args)
end
- @updates
+ [content, @updates]
end
private
- def extractor(opts = {})
- opts.merge!(current_user: current_user, project: project)
-
- Gitlab::SlashCommands::Extractor.new(self.class.command_names(opts))
+ def extractor
+ Gitlab::SlashCommands::Extractor.new(self.class.command_definitions)
end
desc do