Save the list of handlers in a constant

This commit is contained in:
Lin Jen-Shin 2016-06-15 16:31:28 +08:00
parent 5608e1a159
commit 3ced5ae68e

View file

@ -4,8 +4,10 @@ require 'gitlab/email/handler/create_issue_handler'
module Gitlab
module Email
module Handler
HANDLERS = [CreateNoteHandler, CreateIssueHandler]
def self.for(mail, mail_key)
[CreateNoteHandler, CreateIssueHandler].find do |klass|
HANDLERS.find do |klass|
handler = klass.new(mail, mail_key)
break handler if handler.can_handle?
end