Class: Dropbox::API::Raw
- Inherits:
-
Object
- Object
- Dropbox::API::Raw
- Defined in:
- lib/dropbox-api/client/raw.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Raw
constructor
A new instance of Raw.
- #request(endpoint, method, action, data = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Raw
Returns a new instance of Raw.
8 9 10 |
# File 'lib/dropbox-api/client/raw.rb', line 8 def initialize( = {}) @connection = [:connection] end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/dropbox-api/client/raw.rb', line 6 def connection @connection end |
Class Method Details
.add_method(method, action, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dropbox-api/client/raw.rb', line 12 def self.add_method(method, action, = {}) # Add the default root bit, but allow it to be disabled by a config option root = [:root] == false ? '' : "options[:root] ||= Dropbox::API::Config.mode" self.class_eval <<-STR def #{[:as] || action}(options = {}) #{root} request(:#{[:endpoint] || 'main'}, :#{method}, "#{action}", options) end STR end |
Instance Method Details
#request(endpoint, method, action, data = {}) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/dropbox-api/client/raw.rb', line 23 def request(endpoint, method, action, data = {}) action.sub! ':root', Dropbox::API::Util.escape(data.delete(:root).to_s) if action.match ':root' action.sub! ':path', Dropbox::API::Util.escape(data.delete(:path).to_s) if action.match ':path' action = Dropbox::API::Util.remove_double_slashes(action) connection.send(method, endpoint, action, data) end |