Class: UrlSigner::Base
- Inherits:
-
Struct
- Object
- Struct
- UrlSigner::Base
- Defined in:
- lib/url_signer/base.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#hash_method ⇒ Object
Returns the value of attribute hash_method.
-
#key ⇒ Object
Returns the value of attribute key.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, key: nil, hash_method: nil) ⇒ Base
constructor
A new instance of Base.
- #signature ⇒ Object
Constructor Details
#initialize(url, key: nil, hash_method: nil) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/url_signer/base.rb', line 10 def initialize(url, key: nil, hash_method: nil) # load and check url url = URI.parse(url) if url.kind_of?(String) raise "expecting a String or URI instance" unless url.kind_of?(URI) # load and check signing key key ||= ENV['URL_SIGNING_KEY'] raise "You need to provided a signing key to your UrlSigner instance" unless key # load the hash method hash_method ||= Digest::SHA1 super(url, key, hash_method) end |
Instance Attribute Details
#hash_method ⇒ Object
Returns the value of attribute hash_method
8 9 10 |
# File 'lib/url_signer/base.rb', line 8 def hash_method @hash_method end |
#key ⇒ Object
Returns the value of attribute key
8 9 10 |
# File 'lib/url_signer/base.rb', line 8 def key @key end |
#url ⇒ Object
Returns the value of attribute url
8 9 10 |
# File 'lib/url_signer/base.rb', line 8 def url @url end |
Instance Method Details
#signature ⇒ Object
25 26 27 |
# File 'lib/url_signer/base.rb', line 25 def signature compute_signature(url.host, url.path, params) end |