summaryrefslogtreecommitdiff
path: root/app/observers/note_observer.rb
diff options
context:
space:
mode:
authorRobb Kidd <robb@thekidds.org>2012-10-11 13:27:58 -0400
committerRobb Kidd <robb@thekidds.org>2012-10-11 13:27:58 -0400
commit378fe076b6d6bf6d6808a7336a25ebeb3eca7683 (patch)
tree3273b23348d7f19d416e17052a47929db736fcef /app/observers/note_observer.rb
parentbaf94bd732e0e5802a888d95d943c948b7a9e65b (diff)
downloadgitlab-ce-378fe076b6d6bf6d6808a7336a25ebeb3eca7683.tar.gz
Reduce complexity: replace case statement with method lookup.
Diffstat (limited to 'app/observers/note_observer.rb')
-rw-r--r--app/observers/note_observer.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb
index 844848567eb..3d51b9c2e2e 100644
--- a/app/observers/note_observer.rb
+++ b/app/observers/note_observer.rb
@@ -16,16 +16,11 @@ class NoteObserver < ActiveRecord::Observer
protected
def notify_team_of_new_note(note)
- team_without_note_author(note).map do |u|
- case note.noteable_type
- when "Commit"; Notify.note_commit_email(u.id, note.id).deliver
- when "Issue"; Notify.note_issue_email(u.id, note.id).deliver
- when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver
- when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver
- when "Wall"; Notify.note_wall_email(u.id, note.id).deliver
- when "Snippet"; true # no notifications for snippets?
- else
- true
+ notify_method = 'note_' + note.noteable_type.underscore + '_email'
+
+ if Notify.respond_to? notify_method
+ team_without_note_author(note).map do |u|
+ Notify.send(notify_method.to_sym, u.id, note.id).deliver
end
end
end