Skip to content
Snippets Groups Projects
Commit 3caf7bff authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Reduce complexity by extracting it to a method

parent d27095a3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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 = {}
 
Loading
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment