Class: Dscf::Credit::BankStaffCreationService

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
app/services/dscf/credit/bank_staff_creation_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BankStaffCreationService

Returns a new instance of BankStaffCreationService.



30
31
32
# File 'app/services/dscf/credit/bank_staff_creation_service.rb', line 30

def initialize(attributes = {})
  super(attributes)
end

Instance Attribute Details

#bank_staffObject (readonly)

Returns the value of attribute bank_staff.



28
29
30
# File 'app/services/dscf/credit/bank_staff_creation_service.rb', line 28

def bank_staff
  @bank_staff
end

#generated_passwordObject (readonly)

Returns the value of attribute generated_password.



28
29
30
# File 'app/services/dscf/credit/bank_staff_creation_service.rb', line 28

def generated_password
  @generated_password
end

#userObject (readonly)

Returns the value of attribute user.



28
29
30
# File 'app/services/dscf/credit/bank_staff_creation_service.rb', line 28

def user
  @user
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/services/dscf/credit/bank_staff_creation_service.rb', line 34

def call
  ActiveRecord::Base.transaction do
    create_user!
    assign_role!
    create_bank_staff!
    send_welcome_email!

    true
  rescue => e
    errors.add(:base, e.message)
    false
  end
end