Skip to content

Commit

Permalink
Add deprecation warning for WickedPdf.config=
Browse files Browse the repository at this point in the history
This adds a deprecation warning for the old way to set config. Users
have the option to silence the warning if they want to do so.
  • Loading branch information
kevinnio committed Jan 5, 2024
1 parent f7787c8 commit afe4df5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/wicked_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@
class WickedPdf
DEFAULT_BINARY_VERSION = Gem::Version.new('0.9.9')
@@config = {}
cattr_accessor :config
cattr_accessor :config, :silence_deprecations

include Progress

def self.config=(config)
unless @@silence_deprecations
::Kernel.warn "WickedPdf.config= is deprecated and will be removed in future versions. Use WickedPdf.configure instead."
end

@@config = config
end

def self.configure
config = OpenStruct.new(@@config)
yield config
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require 'wicked_pdf'

Rails.backtrace_cleaner.remove_silencers!
WickedPdf.silence_deprecations = true

if (assets_dir = Rails.root.join('app/assets')) && File.directory?(assets_dir)
# Copy CSS file
Expand Down

0 comments on commit afe4df5

Please sign in to comment.