Class: M365ActiveStorage::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- M365ActiveStorage::Railtie
- Defined in:
- lib/m365_active_storage/railtie.rb
Overview
Rails Integration and Railtie
Integrates the m365_active_storage gem into Rails application lifecycle.
Responsibilities
-
Register gem components with Rails during initialization
-
Load helper and controller classes
-
Add callbacks to ActiveStorage::Blob for SharePoint integration
-
Manage file deletion from SharePoint
Initialization Hooks
The Railtie hooks into the after_initialize event to:
-
Load all controller and helper classes from the gem
-
Extend ActiveStorage::Blob with SharePoint-specific before_destroy callback
-
Capture filename information before blob deletion for delayed deletion from SharePoint
File Deletion Flow
When a blob is destroyed and it’s using the SharePoint service:
-
The before_destroy callback captures blob metadata needed for deletion
-
Stores it in PendingDelete for later retrieval
-
The async deletion worker can delete by SharePoint ID or filename fallback