mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 08:21:57 -04:00
Refactor persist method in EmployeeSyncService to use 'local' variable for clarity
This commit is contained in:
@@ -68,18 +68,18 @@ class EmployeeSyncService
|
|||||||
|
|
||||||
# Create or update a local Employee record based on the QBO remote data
|
# Create or update a local Employee record based on the QBO remote data
|
||||||
def persist(remote)
|
def persist(remote)
|
||||||
employee = Employee.find_or_initialize_by(id: remote.id)
|
local = Employee.find_or_initialize_by(id: remote.id)
|
||||||
|
|
||||||
if remote.active?
|
if remote.active?
|
||||||
employee.name = remote.display_name
|
local.name = remote.display_name
|
||||||
|
|
||||||
if employee.changed?
|
if local.changed?
|
||||||
employee.save
|
local.save
|
||||||
log "Updated employee #{remote.id}"
|
log "Updated employee #{remote.id}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if employee.persisted?
|
if local.persisted?
|
||||||
employee.destroy
|
local.destroy
|
||||||
log "Deleted employee #{remote.id}"
|
log "Deleted employee #{remote.id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user