Class: Employees::UpdateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/employees/update_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(employee_params:, erp_user_params:, current_user:, current_company:) ⇒ UpdateService

Returns a new instance of UpdateService.



8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/employees/update_service.rb', line 8

def initialize(
  employee_params:,
  erp_user_params:,
  current_user:,
  current_company:
)
  @employee_params = employee_params
  @erp_user_params = erp_user_params
  @current_user = current_user
  @current_company = current_company
end

Instance Attribute Details

#current_companyObject (readonly)

Returns the value of attribute current_company.



3
4
5
# File 'app/services/employees/update_service.rb', line 3

def current_company
  @current_company
end

#current_userObject (readonly)

Returns the value of attribute current_user.



3
4
5
# File 'app/services/employees/update_service.rb', line 3

def current_user
  @current_user
end

#employee_paramsObject (readonly)

Returns the value of attribute employee_params.



3
4
5
# File 'app/services/employees/update_service.rb', line 3

def employee_params
  @employee_params
end

#erp_user_paramsObject (readonly)

Returns the value of attribute erp_user_params.



3
4
5
# File 'app/services/employees/update_service.rb', line 3

def erp_user_params
  @erp_user_params
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'app/services/employees/update_service.rb', line 20

def call
  ActiveRecord::Base.transaction do
    update_record
    find_and_update_or_create_erp_user
    validate_after_associations

    @employee
  end
end