Sha256: e94f2ee073ff35a62cdd8fa31c1726f9053f3d6f4146a77f2bde97005dd87be6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Lockbox
  class Railtie < Rails::Railtie
    initializer "lockbox" do |app|
      if defined?(Rails.application.credentials)
        # needs to work when lockbox key has a string value
        Lockbox.master_key ||= Rails.application.credentials.try(:lockbox).try(:fetch, :master_key, nil)
      end

      require "lockbox/carrier_wave_extensions" if defined?(CarrierWave)

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

        ActiveStorage::Attached.prepend(Lockbox::ActiveStorageExtensions::Attached)
        ActiveStorage::Attached::Changes::CreateOne.prepend(Lockbox::ActiveStorageExtensions::CreateOne)
        ActiveStorage::Attached::One.prepend(Lockbox::ActiveStorageExtensions::AttachedOne)
        ActiveStorage::Attached::Many.prepend(Lockbox::ActiveStorageExtensions::AttachedMany)

        ActiveSupport.on_load(:active_storage_attachment) do
          prepend Lockbox::ActiveStorageExtensions::Attachment
        end
        ActiveSupport.on_load(:active_storage_blob) do
          prepend Lockbox::ActiveStorageExtensions::Blob
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lockbox-2.0.0 lib/lockbox/railtie.rb