Created
February 24, 2011 08:07
-
-
Save iboard/841907 to your computer and use it in GitHub Desktop.
Usage of CBA, DelayedJob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Referenced in: http://cba.iboard.cc/p/readme | |
class User | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
include Mongoid::Paperclip | |
..... | |
# Notifications | |
after_create :async_notify_on_creation | |
before_destroy :async_notify_on_cancellation | |
before_update :notify_if_confirmed | |
..... | |
private | |
# Inform admin about sign ups and cancellations of accounts | |
def async_notify_on_creation | |
DelayedJob.enqueue('NewSignUpNotifier', Time.now, self.id) | |
end | |
# Inform admin about cancellations of accounts | |
def async_notify_on_cancellation | |
DelayedJob.enqueue('CancelAccountNotifier', Time.now, self.inspect) | |
end | |
# Inform admin if someone confirms an account | |
def notify_if_confirmed | |
if attribute_changed?('confirmed_at') | |
DelayedJob.enqueue('AccountConfirmedNotifier', Time.now, self.id) | |
end | |
end | |
.... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment