Class: CloudApp::Base
Overview
Base class for setting HTTParty configurations globally
Constant Summary collapse
- @@auth =
Define empty auth hash
{}
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.authenticate(email, password) ⇒ Hash
Sets the authentication credentials in a class variable.
-
.bad_response(response) ⇒ Object
Examines a bad response and raises an approriate exception.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ CloudApp::Base
constructor
Create a new CloudApp::Base object.
Constructor Details
#initialize(attributes = {}) ⇒ CloudApp::Base
Create a new CloudApp::Base object.
Only used internally
50 51 52 53 |
# File 'lib/cloudapp/base.rb', line 50 def initialize(attributes = {}) @data = attributes load(@data) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
42 43 44 |
# File 'lib/cloudapp/base.rb', line 42 def data @data end |
Class Method Details
.authenticate(email, password) ⇒ Hash
Sets the authentication credentials in a class variable.
28 29 30 |
# File 'lib/cloudapp/base.rb', line 28 def self.authenticate(email, password) @@auth = {:username => email, :password => password} end |
.bad_response(response) ⇒ Object
Examines a bad response and raises an approriate exception
35 36 37 38 39 40 |
# File 'lib/cloudapp/base.rb', line 35 def self.bad_response(response) if response.class == HTTParty::Response raise ResponseError, response end raise StandardError, "Unkown error" end |