Class: M365ActiveStorage::Railtie

Inherits:
Rails::Railtie
  • Object
show all
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:

  1. Load all controller and helper classes from the gem

  2. Extend ActiveStorage::Blob with SharePoint-specific before_destroy callback

  3. 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:

  1. The before_destroy callback captures blob metadata needed for deletion

  2. Stores it in PendingDelete for later retrieval

  3. The async deletion worker can delete by SharePoint ID or filename fallback

See Also: