Class: Nexo::EventReceiver
- Inherits:
-
Object
- Object
- Nexo::EventReceiver
- Defined in:
- app/lib/nexo/event_receiver.rb
Overview
This callbacks must be called when synchronizables change locally, must not be called when the system is notified of an external element change
Instance Method Summary collapse
- #folder_changed(folder) ⇒ Object
- #folder_discarded(folder) ⇒ Object
- #synchronizable_created(synchronizable) ⇒ Object
- #synchronizable_destroyed(synchronizable) ⇒ Object
- #synchronizable_updated(synchronizable) ⇒ Object
Instance Method Details
#folder_changed(folder) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/lib/nexo/event_receiver.rb', line 23 def folder_changed(folder) return unless folder.sync_internal_changes? if folder.discarded? raise "folder discarded" end FolderSyncJob.perform_later(folder) end |
#folder_discarded(folder) ⇒ Object
32 33 34 35 36 |
# File 'app/lib/nexo/event_receiver.rb', line 32 def folder_discarded(folder) return unless folder.sync_internal_changes? FolderDestroyJob.perform_later(folder) end |
#synchronizable_created(synchronizable) ⇒ Object
5 6 7 |
# File 'app/lib/nexo/event_receiver.rb', line 5 def synchronizable_created(synchronizable) SynchronizableChangedJob.perform_later(synchronizable) end |
#synchronizable_destroyed(synchronizable) ⇒ Object
19 20 21 |
# File 'app/lib/nexo/event_receiver.rb', line 19 def synchronizable_destroyed(synchronizable) folder_service.destroy_elements(synchronizable, :synchronizable_destroyed) end |
#synchronizable_updated(synchronizable) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/lib/nexo/event_receiver.rb', line 9 def synchronizable_updated(synchronizable) if synchronizable.change_is_significative_to_sequence? synchronizable.increment_sequence! end # Even if sequence remains the same the synchronizable may be removed # from some Folder, so we have to always enqueue the job SynchronizableChangedJob.perform_later(synchronizable) end |