Class: Cloudpt::API::Raw
- Inherits:
-
Object
- Object
- Cloudpt::API::Raw
- Defined in:
- lib/cloudpt-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/cloudpt-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/cloudpt-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/cloudpt-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] ||= Cloudpt::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/cloudpt-api/client/raw.rb', line 23 def request(endpoint, method, action, data = {}) action.sub! ':root', data.delete(:root) if action.match ':root' action.sub! ':path', Cloudpt::API::Util.escape(data.delete(:path)) if action.match ':path' action = Cloudpt::API::Util.remove_double_slashes(action) connection.send(method, endpoint, action, data) end |