diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-16 19:59:55 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-17 17:54:24 -0500 |
commit | 8b8a4626c601a13683599fd1a127e2c502af38a3 (patch) | |
tree | 5478e3356c4ab3a02923cb48c8271a97273959fa /lib | |
parent | e07c27fee427195d8d89f6278d0fc12dfeec3588 (diff) | |
download | gitlab-ce-8b8a4626c601a13683599fd1a127e2c502af38a3.tar.gz |
Fix specs and implement fixes based on failing specs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/slash_commands/command_definition.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/slash_commands/dsl.rb | 18 |
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/gitlab/slash_commands/command_definition.rb b/lib/gitlab/slash_commands/command_definition.rb index 187c1c9489f..641c92e77da 100644 --- a/lib/gitlab/slash_commands/command_definition.rb +++ b/lib/gitlab/slash_commands/command_definition.rb @@ -3,8 +3,14 @@ module Gitlab class CommandDefinition attr_accessor :name, :aliases, :description, :params, :condition_block, :action_block - def initialize(name) + def initialize(name, attributes = {}) @name = name + + @aliases = attributes[:aliases] || [] + @description = attributes[:description] || '' + @params = attributes[:params] || [] + @condition_block = attributes[:condition_block] + @action_block = attributes[:action_block] end def all_names diff --git a/lib/gitlab/slash_commands/dsl.rb b/lib/gitlab/slash_commands/dsl.rb index 7b1a094a7e6..50b0937d267 100644 --- a/lib/gitlab/slash_commands/dsl.rb +++ b/lib/gitlab/slash_commands/dsl.rb @@ -17,7 +17,7 @@ module Gitlab # Allows to give a description to the next slash command. # This description is shown in the autocomplete menu. # It accepts a block that will be evaluated with the context given to - # `.command_definitions` or `.command_names`. + # `CommandDefintion#to_h`. # # Example: # @@ -47,7 +47,7 @@ module Gitlab # Allows to define conditions that must be met in order for the command # to be returned by `.command_names` & `.command_definitions`. # It accepts a block that will be evaluated with the context given to - # `.command_definitions`, `.command_names`, and the actual command method. + # `CommandDefintion#to_h`. # # Example: # @@ -73,12 +73,14 @@ module Gitlab def command(*command_names, &block) name, *aliases = command_names - definition = CommandDefinition.new(name) - definition.aliases = aliases - definition.description = @description || '' - definition.params = @params || [] - definition.condition_block = @condition_block - definition.action_block = block + definition = CommandDefinition.new( + name, + aliases: aliases, + description: @description, + params: @params, + condition_block: @condition_block, + action_block: block + ) self.command_definitions << definition |