Skip to content

Commit

Permalink
Only adds the deprecator in the app if Rails supports it
Browse files Browse the repository at this point in the history
Fixes #329.
  • Loading branch information
rafaelfranca committed Aug 2, 2023
1 parent dc3df04 commit 11efc57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/web_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ module WebConsole
def self.logger
(defined?(Rails.logger) && Rails.logger) || (@logger ||= ActiveSupport::Logger.new($stderr))
end

def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("5.0", "WebConsole")
end
end

require "web_console/railtie"
4 changes: 2 additions & 2 deletions lib/web_console/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Railtie < ::Rails::Railtie
end

initializer "web_console.deprecator" do |app|
app.deprecators[:web_console] = ActiveSupport::Deprecation.new("5.0", "WebConsole")
app.deprecators[:web_console] = WebConsole.deprecator if app.respond_to?(:deprecators)
end

initializer "web_console.permissions" do
Expand All @@ -67,7 +67,7 @@ def web_console_permissions
when config.web_console.allowed_ips
config.web_console.allowed_ips
when config.web_console.whitelisted_ips
Rails.application.deprecators[:web_console].warn(<<-MSG.squish)
WebConsole.deprecator.warn(<<-MSG.squish)
The config.web_console.whitelisted_ips is deprecated and will be ignored in future release of web_console.
Please use config.web_console.allowed_ips instead.
MSG
Expand Down

0 comments on commit 11efc57

Please sign in to comment.