Class: Jumbotron::Services::Canonical::AttachProviderIdentities

Inherits:
CommandTower::Services::ApplicationService
  • Object
show all
Defined in:
app/services/jumbotron/services/canonical/attach_provider_identities.rb

Instance Method Summary collapse

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/jumbotron/services/canonical/attach_provider_identities.rb', line 10

def call
  conflict = refs.find { |ref| conflicting_identity?(ref) }
  if conflict
    context.fail!(
      application_error: Jumbotron::Errors::Canonical::ProviderIdentityConflictError.new
    )
    return
  end

  refs.each { |ref| ensure_identity!(ref) }
  context.target = target
rescue ActiveRecord::RecordInvalid => e
  context.fail!(
    application_error: Jumbotron::Errors::Canonical::MutationFailedError.new(
      details: { message: e.message }
    )
  )
end