Reduce complexity: replace case statement with method lookup.
Created by: robbkidd
Code climate gave NoteObserver
a "B" because of the complex notify_team_of_new_note
method that used a case statement. According to straight code analysis, this change halves the complexity of the method.
A concrete benefit of this change is that it reduces the number of code changes needed to add an email notification to a Note
on a new model--or, say, Snippet
with no email currently implemented. One would only have to make changes to Notify
(add a note_snippet_email
method and view) and update the tests for this method. No further change needed within the method itself.