Module: Models::EmployeePhonePresence
- Extended by:
- ActiveSupport::Concern
- Included in:
- Employee
- Defined in:
- app/concerns/models/employee_phone_presence.rb
Overview
PBX presence, extension status, and work-from-home checks for Employee.
Reads go through the employee's EmployeePhoneStatus; #set_presence
updates it and syncs the switchboard (broadcast in development,
SyncPhoneStatusWorker otherwise).
Instance Method Summary collapse
-
#auto_away_after ⇒ String?
Auto-away time of day, formatted like "05:30 pm".
-
#pbx_did ⇒ String?
The employee's direct-inward-dial number (contact point detail).
-
#pbx_did_contact_point ⇒ ContactPoint?
The DID contact point backing the employee's PBX line.
-
#pbx_extension ⇒ String?
The employee's PBX extension.
-
#presence ⇒ Symbol
The employee's current primary presence as a Symbol,
:unknownwhen none is set. -
#presence_timestamp ⇒ Integer?
Unix timestamp of when the current presence was set.
-
#set_presence(new_presence, sub_presence = nil) ⇒ String, ...
Updates the employee's PBX presence and synchronizes it with the phone system.
-
#sub_presence ⇒ Symbol?
The employee's current secondary presence.
-
#working_from_home? ⇒ Boolean?
(also: #is_working_from_home?)
Whether the employee is currently flagged as working from home.
-
#working_from_home_number ⇒ String?
Phone number to reach the employee while working from home.
Instance Method Details
#auto_away_after ⇒ String?
Auto-away time of day, formatted like "05:30 pm".
98 99 100 |
# File 'app/concerns/models/employee_phone_presence.rb', line 98 def auto_away_after employee_phone_status.try(:auto_away_after).try(:strftime, '%I:%M %P') end |
#pbx_did ⇒ String?
The employee's direct-inward-dial number (contact point detail).
26 27 28 |
# File 'app/concerns/models/employee_phone_presence.rb', line 26 def pbx_did pbx_did_contact_point&.detail end |
#pbx_did_contact_point ⇒ ContactPoint?
The DID contact point backing the employee's PBX line.
19 20 21 |
# File 'app/concerns/models/employee_phone_presence.rb', line 19 def pbx_did_contact_point employee_phone_status&.contact_point end |
#pbx_extension ⇒ String?
The employee's PBX extension.
33 34 35 |
# File 'app/concerns/models/employee_phone_presence.rb', line 33 def pbx_extension employee_phone_status&.extension end |
#presence ⇒ Symbol
The employee's current primary presence as a Symbol, :unknown when none
is set.
77 78 79 |
# File 'app/concerns/models/employee_phone_presence.rb', line 77 def presence employee_phone_status.try(:presence).try(:to_sym) || :unknown end |
#presence_timestamp ⇒ Integer?
Unix timestamp of when the current presence was set.
91 92 93 |
# File 'app/concerns/models/employee_phone_presence.rb', line 91 def employee_phone_status.try(:date_set).try(:to_i) end |
#set_presence(new_presence, sub_presence = nil) ⇒ String, ...
Updates the employee's PBX presence and synchronizes it with the phone system.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/concerns/models/employee_phone_presence.rb', line 57 def set_presence(new_presence, sub_presence = nil) eps = employee_phone_status || build_employee_phone_status eps.presence = new_presence eps.sub_presence = sub_presence if eps.presence_changed? || eps.sub_presence_changed? eps.date_set = Time.current eps.last_alert = nil eps.save end if Rails.env.development? eps.broadcast_agent_status else SyncPhoneStatusWorker.perform_async(id) end end |
#sub_presence ⇒ Symbol?
The employee's current secondary presence.
84 85 86 |
# File 'app/concerns/models/employee_phone_presence.rb', line 84 def sub_presence employee_phone_status.try(:sub_presence).try(:to_sym) end |
#working_from_home? ⇒ Boolean? Also known as: is_working_from_home?
Whether the employee is currently flagged as working from home.
40 41 42 |
# File 'app/concerns/models/employee_phone_presence.rb', line 40 def working_from_home? employee_phone_status.try(:working_from_home) end |
#working_from_home_number ⇒ String?
Phone number to reach the employee while working from home.
48 49 50 |
# File 'app/concerns/models/employee_phone_presence.rb', line 48 def working_from_home_number employee_phone_status.try(:working_from_home_number) end |