Class: Imgproxy::Config
- Inherits:
-
Object
- Object
- Imgproxy::Config
- Defined in:
- lib/imgproxy/config.rb
Overview
Imgproxy config
Instance Attribute Summary collapse
-
#endpoint ⇒ String
Imgproxy endpoint.
-
#key ⇒ String
Imgproxy signature key.
-
#salt ⇒ String
Imgproxy signature salt.
-
#signature_size ⇒ Integer
Imgproxy signature size.
-
#use_short_options ⇒ Boolean
Use short processing option names (
rsforresize,gforgravity, etc).
Instance Method Summary collapse
-
#hex_key=(value) ⇒ Object
Decodes hex-encoded key and sets it to #key.
-
#hex_salt=(value) ⇒ Object
Decodes hex-encoded salt and sets it to #salt.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#url_adapters ⇒ Imgproxy::UrlAdapters
URL adapters config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 23 |
# File 'lib/imgproxy/config.rb', line 20 def initialize self.signature_size = 32 self. = true end |
Instance Attribute Details
#endpoint ⇒ String
Returns imgproxy endpoint.
8 9 10 |
# File 'lib/imgproxy/config.rb', line 8 def endpoint @endpoint end |
#key ⇒ String
Returns imgproxy signature key.
10 11 12 |
# File 'lib/imgproxy/config.rb', line 10 def key @key end |
#salt ⇒ String
Returns imgproxy signature salt.
12 13 14 |
# File 'lib/imgproxy/config.rb', line 12 def salt @salt end |
#signature_size ⇒ Integer
Returns imgproxy signature size. Defaults to 32.
14 15 16 |
# File 'lib/imgproxy/config.rb', line 14 def signature_size @signature_size end |
#use_short_options ⇒ Boolean
Returns use short processing option names (rs for resize, g for gravity, etc). Defaults to true.
18 19 20 |
# File 'lib/imgproxy/config.rb', line 18 def end |
Instance Method Details
#hex_key=(value) ⇒ Object
Decodes hex-encoded key and sets it to #key
28 29 30 |
# File 'lib/imgproxy/config.rb', line 28 def hex_key=(value) self.key = value.nil? ? nil : [value].pack("H*") end |
#hex_salt=(value) ⇒ Object
Decodes hex-encoded salt and sets it to #salt
35 36 37 |
# File 'lib/imgproxy/config.rb', line 35 def hex_salt=(value) self.salt = value.nil? ? nil : [value].pack("H*") end |
#url_adapters ⇒ Imgproxy::UrlAdapters
URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.
Imgproxy.configure do |config|
config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new
end
Imgproxy.url_for(user.avatar)
49 50 51 |
# File 'lib/imgproxy/config.rb', line 49 def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end |