Class: Kanoko::Configure
- Inherits:
-
Object
- Object
- Kanoko::Configure
- Defined in:
- lib/kanoko/configure.rb
Instance Attribute Summary collapse
-
#digest_func ⇒ Object
Returns the value of attribute digest_func.
-
#hash_proc ⇒ Object
Returns the value of attribute hash_proc.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Method Summary collapse
-
#initialize ⇒ Configure
constructor
digest_func expect String secret_key expect String hash_proc expect Proc.
Constructor Details
#initialize ⇒ Configure
digest_func expect String secret_key expect String hash_proc expect Proc
example:
Kanoko.configure do |c|
c.digest_func = "sha1"
c.secret_key = "secret"
end
Kanoko.path_for(:resize, "100x100") #=> "/hashing_value/resize/100x100"
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kanoko/configure.rb', line 19 def initialize @digest_func = ENV['KANOKO_DIGEST_FUNC'] @secret_key = ENV['KANOKO_SECRET_KEY'] @hash_proc = lambda do |*args| if @digest_func.nil? || @secret_key.nil? fail ConfigureError, "`digest_func' and `secret_key' must be set" end Base64.urlsafe_encode64( OpenSSL::HMAC.digest( @digest_func, @secret_key, args.map(&:to_s).join(','), ), ) end end |
Instance Attribute Details
#digest_func ⇒ Object
Returns the value of attribute digest_func.
7 8 9 |
# File 'lib/kanoko/configure.rb', line 7 def digest_func @digest_func end |
#hash_proc ⇒ Object
Returns the value of attribute hash_proc.
7 8 9 |
# File 'lib/kanoko/configure.rb', line 7 def hash_proc @hash_proc end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
7 8 9 |
# File 'lib/kanoko/configure.rb', line 7 def secret_key @secret_key end |