Class: ChatMessage::MergeMessage

Inherits:
BaseMessage show all
Defined in:
app/models/project_services/chat_message/merge_message.rb

Constant Summary

Constants inherited from BaseMessage

BaseMessage::RELATIVE_LINK_REGEX

Instance Attribute Summary collapse

Attributes inherited from BaseMessage

#markdown, #project_name, #project_url, #user_avatar, #user_full_name, #user_name

Instance Method Summary collapse

Methods inherited from BaseMessage

#fallback, #pretext, #summary, #user_combined_name

Constructor Details

#initialize(params) ⇒ MergeMessage

Returns a new instance of MergeMessage.


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/project_services/chat_message/merge_message.rb', line 12

def initialize(params)
  super

  obj_attr = params[:object_attributes]
  obj_attr = HashWithIndifferentAccess.new(obj_attr)
  @merge_request_iid = obj_attr[:iid]
  @source_branch = obj_attr[:source_branch]
  @target_branch = obj_attr[:target_branch]
  @action = obj_attr[:action]
  @state = obj_attr[:state]
  @title = format_title(obj_attr[:title])
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action


8
9
10
# File 'app/models/project_services/chat_message/merge_message.rb', line 8

def action
  @action
end

#merge_request_iidObject (readonly)

Returns the value of attribute merge_request_iid


5
6
7
# File 'app/models/project_services/chat_message/merge_message.rb', line 5

def merge_request_iid
  @merge_request_iid
end

#source_branchObject (readonly)

Returns the value of attribute source_branch


6
7
8
# File 'app/models/project_services/chat_message/merge_message.rb', line 6

def source_branch
  @source_branch
end

#stateObject (readonly)

Returns the value of attribute state


9
10
11
# File 'app/models/project_services/chat_message/merge_message.rb', line 9

def state
  @state
end

#target_branchObject (readonly)

Returns the value of attribute target_branch


7
8
9
# File 'app/models/project_services/chat_message/merge_message.rb', line 7

def target_branch
  @target_branch
end

#titleObject (readonly)

Returns the value of attribute title


10
11
12
# File 'app/models/project_services/chat_message/merge_message.rb', line 10

def title
  @title
end

Instance Method Details

#activityObject


29
30
31
32
33
34
35
36
# File 'app/models/project_services/chat_message/merge_message.rb', line 29

def activity
  {
    title: "Merge Request #{state_or_action_text} by #{user_combined_name}",
    subtitle: "in #{project_link}",
    text: merge_request_link,
    image: user_avatar
  }
end

#attachmentsObject


25
26
27
# File 'app/models/project_services/chat_message/merge_message.rb', line 25

def attachments
  []
end