Class: Trackers::StaffService

Inherits:
Object
  • Object
show all
Defined in:
app/services/partner_service/trackers/staff_service.rb

Overview

The StaffService class is responsible for tracking changes related to staff creation and deletion. It records navigation details, timestamps, and change descriptions for better traceability.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#changesObject

Returns the value of attribute changes.



5
6
7
# File 'app/services/partner_service/trackers/staff_service.rb', line 5

def changes
  @changes
end

Returns the value of attribute footer_text.



5
6
7
# File 'app/services/partner_service/trackers/staff_service.rb', line 5

def footer_text
  @footer_text
end

Returns the value of attribute navigation.



5
6
7
# File 'app/services/partner_service/trackers/staff_service.rb', line 5

def navigation
  @navigation
end

Instance Method Details

#track_staff_created(staff) ⇒ void

This method returns an undefined value.

Tracks the creation of a staff member, recording their details and generating a change log.

Parameters:

  • staff (Staff)

    The staff object that has been created.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/partner_service/trackers/staff_service.rb', line 11

def track_staff_created(staff)
  @navigation = 'staffs'
  @footer_text = Time.zone.now.strftime('%d %B %Y, %H:%M')
  @changes = {
    staff: {
      type: 'staff',
      staff: {
        id: staff.id,
        name: staff.name,
        email: staff.email,
        role: 'Staff',
      },
      label: 'user has been created',
    },
  }
end

#track_staff_deleted(staff) ⇒ void

This method returns an undefined value.

Tracks the deletion of a staff member, recording their details and generating a change log.

Parameters:

  • staff (Staff)

    The staff object that has been deleted.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/services/partner_service/trackers/staff_service.rb', line 32

def track_staff_deleted(staff)
  @navigation = 'staffs'
  @footer_text = Time.zone.now.strftime('%d %B %Y, %H:%M')
  @changes = {
    staff: {
      type: 'staff',
      staff: {
        id: staff.id,
        name: staff.name,
        email: staff.email,
        role: 'Staff',
      },
      label: 'Staff has been deleted',
    },
  }
end