Sha256: 70e27cc8caea6abfc391c0391da0845dcde94b27884a13485ac2913f8bd667da

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true
require 'as_deprecation_tracker/receiver'

module ASDeprecationTracker
  # Railtie to register for deprecation notifications
  class Railtie < ::Rails::Railtie
    initializer 'as_deprecation_tracker.deprecation_notifications', after: :load_environment_config, if: -> { ASDeprecationTracker.active? } do
      Receiver.attach_to :rails, ASDeprecationTracker.receiver
      ActiveSupport::Deprecation.behavior = :notify if ASDeprecationTracker.config.register_behavior?

      whitelist = ASDeprecationTracker.config.whitelist_file
      ([Rails.root] + engine_roots).each do |root|
        engine_whitelist = File.join(root, whitelist)
        ASDeprecationTracker.whitelist.load_file(engine_whitelist) if File.exist?(engine_whitelist)
      end
    end

    private

    def engine_roots
      ::Rails::Engine.descendants.map { |engine| engine.root rescue nil }.compact.uniq # rubocop:disable Style/RescueModifier
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
as_deprecation_tracker-1.5.0 lib/as_deprecation_tracker/railtie.rb
as_deprecation_tracker-1.4.1 lib/as_deprecation_tracker/railtie.rb
as_deprecation_tracker-1.4.0 lib/as_deprecation_tracker/railtie.rb