Sha256: 281110d667b3f80c9e071cde23e696cb8cd103a44e7c661b51160fe51f9d1058

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

module Lockbox
  class Railtie < Rails::Railtie
    initializer "lockbox" do |app|
      require "lockbox/carrier_wave_extensions" if defined?(CarrierWave)

      if defined?(ActiveStorage)
        require "lockbox/active_storage_extensions"

        ActiveStorage::Attached.prepend(Lockbox::ActiveStorageExtensions::Attached)
        if ActiveStorage::VERSION::MAJOR >= 6
          ActiveStorage::Attached::Changes::CreateOne.prepend(Lockbox::ActiveStorageExtensions::CreateOne)
        end
        ActiveStorage::Attached::One.prepend(Lockbox::ActiveStorageExtensions::AttachedOne)
        ActiveStorage::Attached::Many.prepend(Lockbox::ActiveStorageExtensions::AttachedMany)

        # use load hooks when possible
        if ActiveStorage::VERSION::MAJOR >= 6
          ActiveSupport.on_load(:active_storage_attachment) do
            include Lockbox::ActiveStorageExtensions::Attachment
          end
          ActiveSupport.on_load(:active_storage_blob) do
            prepend Lockbox::ActiveStorageExtensions::Blob
          end
        else
          app.config.to_prepare do
            ActiveStorage::Attachment.include(Lockbox::ActiveStorageExtensions::Attachment)
            ActiveStorage::Blob.prepend(Lockbox::ActiveStorageExtensions::Blob)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lockbox-0.6.0 lib/lockbox/railtie.rb
lockbox-0.5.0 lib/lockbox/railtie.rb
lockbox-0.4.9 lib/lockbox/railtie.rb
lockbox-0.4.8 lib/lockbox/railtie.rb
lockbox-0.4.7 lib/lockbox/railtie.rb
lockbox-0.4.6 lib/lockbox/railtie.rb
lockbox-0.4.5 lib/lockbox/railtie.rb
lockbox-0.4.4 lib/lockbox/railtie.rb
lockbox-0.4.3 lib/lockbox/railtie.rb
lockbox-0.4.2 lib/lockbox/railtie.rb