Class: Gitlab::SlashCommands::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/slash_commands/base_command.rb

Constant Summary collapse

QUERY_LIMIT =
5

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, chat_name, params = {}) ⇒ BaseCommand

Returns a new instance of BaseCommand.



38
39
40
41
42
43
# File 'lib/gitlab/slash_commands/base_command.rb', line 38

def initialize(project, chat_name, params = {})
  @project = project
  @current_user = chat_name.user
  @params = params.dup
  @chat_name = chat_name
end

Instance Attribute Details

#chat_nameObject

Returns the value of attribute chat_name.



36
37
38
# File 'lib/gitlab/slash_commands/base_command.rb', line 36

def chat_name
  @chat_name
end

#current_userObject

Returns the value of attribute current_user.



36
37
38
# File 'lib/gitlab/slash_commands/base_command.rb', line 36

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params.



36
37
38
# File 'lib/gitlab/slash_commands/base_command.rb', line 36

def params
  @params
end

#projectObject

Returns the value of attribute project.



36
37
38
# File 'lib/gitlab/slash_commands/base_command.rb', line 36

def project
  @project
end

Class Method Details

.allowed?(_user, _ability) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gitlab/slash_commands/base_command.rb', line 20

def self.allowed?(_user, _ability)
  true
end

.available?(_project) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/gitlab/slash_commands/base_command.rb', line 16

def self.available?(_project)
  raise NotImplementedError
end

.can?(object, action, subject) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gitlab/slash_commands/base_command.rb', line 24

def self.can?(object, action, subject)
  Ability.allowed?(object, action, subject)
end

.help_messageObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/gitlab/slash_commands/base_command.rb', line 12

def self.help_message
  raise NotImplementedError
end

.match(_text) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/gitlab/slash_commands/base_command.rb', line 8

def self.match(_text)
  raise NotImplementedError
end

Instance Method Details

#collectionObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/gitlab/slash_commands/base_command.rb', line 32

def collection
  raise NotImplementedError
end

#execute(_) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/gitlab/slash_commands/base_command.rb', line 28

def execute(_)
  raise NotImplementedError
end