Class: WickedPdf::Configuration
- Inherits:
-
Object
- Object
- WickedPdf::Configuration
- Defined in:
- lib/wicked_pdf/configuration.rb
Overview
Global gem configuration, set via WickedPdf.configure or by assigning a Hash to WickedPdf.config (kept for backward compatibility).
Two kinds of values live here:
- Typed settings, declared as accessors below, which control the gem itself (binary location, middleware URLs, asset handling).
- default_options, a Hash of wkhtmltopdf render options (:footer, :orientation, :dpi, ...) merged under every render's own options. Unknown keys assigned through a Hash or #[]= land here.
Constant Summary collapse
- SETTINGS =
[ :exe_path, :basic_auth, :root_url, :default_protocol, :expect_gzipped_remote_assets, :enable_local_file_access, :cache_assets ].freeze
Instance Attribute Summary collapse
-
#default_options ⇒ Object
readonly
Returns the value of attribute default_options.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 |
# File 'lib/wicked_pdf/configuration.rb', line 32 def initialize @basic_auth = false @enable_local_file_access = true @cache_assets = false @default_options = {} end |
Instance Attribute Details
#default_options ⇒ Object (readonly)
Returns the value of attribute default_options.
24 25 26 |
# File 'lib/wicked_pdf/configuration.rb', line 24 def @default_options end |
Class Method Details
.from_hash(hash) ⇒ Object
26 27 28 29 30 |
# File 'lib/wicked_pdf/configuration.rb', line 26 def self.from_hash(hash) new.tap do |config| (hash || {}).each { |key, value| config[key] = value } end end |
Instance Method Details
#[](key) ⇒ Object
47 48 49 |
# File 'lib/wicked_pdf/configuration.rb', line 47 def [](key) setting?(key) ? public_send(key) : [key.to_sym] end |
#[]=(key, value) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/wicked_pdf/configuration.rb', line 39 def []=(key, value) if setting?(key) public_send("#{key}=", value) else [key.to_sym] = value end end |
#to_h ⇒ Object
51 52 53 54 |
# File 'lib/wicked_pdf/configuration.rb', line 51 def to_h settings = SETTINGS.to_h { |key| [key, public_send(key)] } settings.compact.merge() end |