Class: Emails::CreateService

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

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #user

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Emails::BaseService

Instance Method Details

#execute(extra_params = {}) ⇒ Object


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

def execute(extra_params = {})
  skip_confirmation = params.delete(:skip_confirmation)

  user.emails.create(params.merge(extra_params)).tap do |email|
    email&.confirm if skip_confirmation && current_user.admin?
  end
end