[#123] Port the send_notification feature to aaj

This commit is contained in:
Eric Davis 2011-05-13 10:56:22 -07:00
parent 216619d376
commit 23ef9fedef
1 changed files with 18 additions and 1 deletions

View File

@ -16,10 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class JournalObserver < ActiveRecord::Observer
attr_accessor :send_notification
def after_create(journal)
if journal.type == "IssueJournal" and journal.version > 1
if journal.type == "IssueJournal" and journal.version > 1 and self.send_notification
after_create_issue_journal(journal)
end
clear_notification
end
def after_create_issue_journal(journal)
@ -30,4 +33,18 @@ class JournalObserver < ActiveRecord::Observer
Mailer.deliver_issue_edit(journal)
end
end
# Wrap send_notification so it defaults to true, when it's nil
def send_notification
return true if @send_notification.nil?
return @send_notification
end
private
# Need to clear the notification setting after each usage otherwise it might be cached
def clear_notification
@send_notification = true
end
end