Class: SlackService::NoteMessage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseMessage

#fallback, #pretext

Constructor Details

#initialize(params) ⇒ NoteMessage


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/project_services/slack_service/note_message.rb', line 11

def initialize(params)
  params = HashWithIndifferentAccess.new(params)
  @user_name = params[:user][:name]
  @project_name = params[:project_name]
  @project_url = params[:project_url]

  obj_attr = params[:object_attributes]
  obj_attr = HashWithIndifferentAccess.new(obj_attr)
  @note = obj_attr[:note]
  @note_url = obj_attr[:url]
  noteable_type = obj_attr[:noteable_type]

  case noteable_type
  when "Commit"
    create_commit_note(HashWithIndifferentAccess.new(params[:commit]))
  when "Issue"
    create_issue_note(HashWithIndifferentAccess.new(params[:issue]))
  when "MergeRequest"
    create_merge_note(HashWithIndifferentAccess.new(params[:merge_request]))
  when "Snippet"
    create_snippet_note(HashWithIndifferentAccess.new(params[:snippet]))
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message


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

def message
  @message
end

#noteObject (readonly)

Returns the value of attribute note


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

def note
  @note
end

#note_urlObject (readonly)

Returns the value of attribute note_url


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

def note_url
  @note_url
end

#project_nameObject (readonly)

Returns the value of attribute project_name


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

def project_name
  @project_name
end

#titleObject (readonly)

Returns the value of attribute title


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

def title
  @title
end

#user_nameObject (readonly)

Returns the value of attribute user_name


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

def user_name
  @user_name
end

Instance Method Details

#attachmentsObject


35
36
37
# File 'app/models/project_services/slack_service/note_message.rb', line 35

def attachments
  description_message
end