Class: EventDispatchers::InvalidEmployeeEventDispatcher
- Inherits:
-
BaseEventDispatcher
- Object
- BaseEventDispatcher
- EventDispatchers::InvalidEmployeeEventDispatcher
- Defined in:
- app/notifications/event_dispatchers/invalid_employee_event_dispatcher.rb
Instance Attribute Summary
Attributes inherited from BaseEventDispatcher
Instance Method Summary collapse
Methods inherited from BaseEventDispatcher
Constructor Details
This class inherits a constructor from EventDispatchers::BaseEventDispatcher
Instance Method Details
#dispatch ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/notifications/event_dispatchers/invalid_employee_event_dispatcher.rb', line 5 def dispatch Employee.where(company_id: company_id).find_each do |employee| next if employee.valid? ReferenceEvent.find_or_create_by!( slug: ReferenceEvent::Slugs::INVALID_EMPLOYEE, level: ReferenceEvent::Levels::ERROR, company_id: company_id, reference: employee, end_at: nil ).tap do |reference_event| reference_event.update!( last_verified_at: Time.current ) end end end |