Class: DropboxApi::MiddleWare::PathRoot
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- DropboxApi::MiddleWare::PathRoot
- Defined in:
- lib/dropbox_api/middleware/path_root.rb
Constant Summary collapse
- HEADER_NAME =
'Dropbox-API-Path-Root'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ PathRoot
constructor
A new instance of PathRoot.
- #namespace_id ⇒ Object
- #namespace_id_header_value ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ PathRoot
Returns a new instance of PathRoot.
6 7 8 9 |
# File 'lib/dropbox_api/middleware/path_root.rb', line 6 def initialize(app, = {}) super(app) @options = end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/dropbox_api/middleware/path_root.rb', line 27 def call(env) if !namespace_id.nil? env[:request_headers][HEADER_NAME] ||= namespace_id_header_value end @app.call env end |
#namespace_id ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/dropbox_api/middleware/path_root.rb', line 11 def namespace_id if @options[:namespace_id].nil? return nil else return @options[:namespace_id] end end |
#namespace_id_header_value ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/dropbox_api/middleware/path_root.rb', line 19 def namespace_id_header_value JSON.dump( DropboxApi::Metadata::NamespaceId.new({ 'namespace_id' => namespace_id }).to_hash ) end |