Class: Emails::DestroyService

Inherits:
BaseService show all
Defined in:
app/services/emails/destroy_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #user

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #notification_service

Constructor Details

This class inherits a constructor from Emails::BaseService

Instance Method Details

#execute(email) ⇒ Object

Raises:

  • (StandardError)


5
6
7
8
9
# File 'app/services/emails/destroy_service.rb', line 5

def execute(email)
  raise StandardError, 'Cannot delete primary email' if email.user_primary_email?

  email.destroy && update_secondary_emails!(email.email)
end