Class: SlackService::PushMessage

Inherits:
BaseMessage show all
Defined in:
app/models/project_services/slack_service/push_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseMessage

#fallback

Constructor Details

#initialize(params) ⇒ PushMessage


12
13
14
15
16
17
18
19
20
21
# File 'app/models/project_services/slack_service/push_message.rb', line 12

def initialize(params)
  @after = params[:after]
  @before = params[:before]
  @commits = params.fetch(:commits, [])
  @project_name = params[:project_name]
  @project_url = params[:project_url]
  @ref_type = Gitlab::Git.tag_ref?(params[:ref]) ? 'tag' : 'branch'
  @ref = Gitlab::Git.ref_name(params[:ref])
  @user_name = params[:user_name]
end

Instance Attribute Details

#afterObject (readonly)

Returns the value of attribute after


3
4
5
# File 'app/models/project_services/slack_service/push_message.rb', line 3

def after
  @after
end

#beforeObject (readonly)

Returns the value of attribute before


4
5
6
# File 'app/models/project_services/slack_service/push_message.rb', line 4

def before
  @before
end

#commitsObject (readonly)

Returns the value of attribute commits


5
6
7
# File 'app/models/project_services/slack_service/push_message.rb', line 5

def commits
  @commits
end

#project_nameObject (readonly)

Returns the value of attribute project_name


6
7
8
# File 'app/models/project_services/slack_service/push_message.rb', line 6

def project_name
  @project_name
end

#project_urlObject (readonly)

Returns the value of attribute project_url


7
8
9
# File 'app/models/project_services/slack_service/push_message.rb', line 7

def project_url
  @project_url
end

#refObject (readonly)

Returns the value of attribute ref


8
9
10
# File 'app/models/project_services/slack_service/push_message.rb', line 8

def ref
  @ref
end

#ref_typeObject (readonly)

Returns the value of attribute ref_type


9
10
11
# File 'app/models/project_services/slack_service/push_message.rb', line 9

def ref_type
  @ref_type
end

#user_nameObject (readonly)

Returns the value of attribute user_name


10
11
12
# File 'app/models/project_services/slack_service/push_message.rb', line 10

def user_name
  @user_name
end

Instance Method Details

#attachmentsObject


27
28
29
30
31
# File 'app/models/project_services/slack_service/push_message.rb', line 27

def attachments
  return [] if new_branch? || removed_branch?

  commit_message_attachments
end

#pretextObject


23
24
25
# File 'app/models/project_services/slack_service/push_message.rb', line 23

def pretext
  format(message)
end