diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-30 01:18:35 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-30 01:18:35 +0800 |
commit | 3caf7bffdc9cffb0ff60af25cb97b19f672cdb63 (patch) | |
tree | 7e74dc65a03fa3e05976f4e40649cd58339fca21 /app | |
parent | d27095a36a5d8c83182771d7548a13fcc9188e3c (diff) | |
download | gitlab-ce-3caf7bffdc9cffb0ff60af25cb97b19f672cdb63.tar.gz |
Reduce complexity by extracting it to a method
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_services/slack_service.rb | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 6584646e998..4e14a979833 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -64,23 +64,7 @@ class SlackService < Service # 'close' action. Ignore update events for now to prevent duplicate # messages from arriving. - message = \ - case object_kind - when "push", "tag_push" - PushMessage.new(data) - when "issue" - IssueMessage.new(data) unless is_update?(data) - when "merge_request" - MergeMessage.new(data) unless is_update?(data) - when "note" - NoteMessage.new(data) - when "build" - BuildMessage.new(data) if should_build_be_notified?(data) - when "pipeline" - PipelineMessage.new(data) if should_pipeline_be_notified?(data) - when "wiki_page" - WikiPageMessage.new(data) - end + message = get_message(object_kind, data) opt = {} @@ -109,6 +93,25 @@ class SlackService < Service private + def get_message(object_kind, data) + case object_kind + when "push", "tag_push" + PushMessage.new(data) + when "issue" + IssueMessage.new(data) unless is_update?(data) + when "merge_request" + MergeMessage.new(data) unless is_update?(data) + when "note" + NoteMessage.new(data) + when "build" + BuildMessage.new(data) if should_build_be_notified?(data) + when "pipeline" + PipelineMessage.new(data) if should_pipeline_be_notified?(data) + when "wiki_page" + WikiPageMessage.new(data) + end + end + def get_channel_field(event) field_name = event_channel_name(event) self.public_send(field_name) |