Class: OpenGraphPlus::Signature::SignedPath
- Inherits:
-
Object
- Object
- OpenGraphPlus::Signature::SignedPath
- Defined in:
- lib/opengraphplus/signature/url.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #build(*segments, **params) ⇒ Object
- #generator ⇒ Object
-
#initialize(prefix:, api_key:, base_uri:) ⇒ SignedPath
constructor
A new instance of SignedPath.
Constructor Details
#initialize(prefix:, api_key:, base_uri:) ⇒ SignedPath
Returns a new instance of SignedPath.
24 25 26 27 28 |
# File 'lib/opengraphplus/signature/url.rb', line 24 def initialize(prefix:, api_key:, base_uri:) @prefix = prefix @api_key = api_key @base_uri = base_uri end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
22 23 24 |
# File 'lib/opengraphplus/signature/url.rb', line 22 def api_key @api_key end |
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
22 23 24 |
# File 'lib/opengraphplus/signature/url.rb', line 22 def base_uri @base_uri end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
22 23 24 |
# File 'lib/opengraphplus/signature/url.rb', line 22 def prefix @prefix end |
Instance Method Details
#build(*segments, **params) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/opengraphplus/signature/url.rb', line 34 def build(*segments, **params) signed_path = File.join("/", *segments.map(&:to_s)) path_and_query = params.empty? ? signed_path : "#{signed_path}?#{URI.encode_www_form(params)}" signature = generator.generate(path_and_query) base_uri.dup.tap do |uri| uri.path = File.join(prefix, signature, *segments.map(&:to_s)) uri.query = URI.encode_www_form(params) unless params.empty? end.to_s end |