module JamRuby
  class UserObserver < ActiveRecord::Observer

    observe JamRuby::User

    def after_save(user)
      if user.updating_email && !user.errors.any?
        UserMailer.updating_email(user).deliver_now
      elsif user.updated_email && !user.errors.any?
        UserMailer.updated_email(user).deliver_now
      elsif user.setting_password && !user.errors.any?
        UserMailer.password_changed(user).deliver_now
      end
    end
  end
end