Class: Raven::Response
- Inherits:
-
Object
- Object
- Raven::Response
- Defined in:
- lib/rb_raven_api/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(http, _code, _path, _params) ⇒ Response
constructor
Initializing response object to be returned from API calls, used internally.
-
#parsed_body ⇒ Hashie::Mash
Parses JSON body of request and returns a Hashie::Mash.
-
#success? ⇒ Boolean
Convenience method to determine if request was successfull or not.
Constructor Details
#initialize(http, _code, _path, _params) ⇒ Response
Initializing response object to be returned from API calls, used internally.
11 12 13 14 |
# File 'lib/rb_raven_api/response.rb', line 11 def initialize(http, _code, _path, _params) # @private @success, @body, @errors = http.success, http.response, http.errors @code, @path, @params = _code, _path, _params end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def code @code end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def errors @errors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def path @path end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
5 6 7 |
# File 'lib/rb_raven_api/response.rb', line 5 def success @success end |
Instance Method Details
#parsed_body ⇒ Hashie::Mash
Parses JSON body of request and returns a Hashie::Mash
30 31 32 33 34 |
# File 'lib/rb_raven_api/response.rb', line 30 def parsed_body hash = JSON.parse(@body) rescue {} return hash if hash.is_a?(Array) Hashie::Mash.new hash end |
#success? ⇒ Boolean
Convenience method to determine if request was successfull or not
21 22 23 |
# File 'lib/rb_raven_api/response.rb', line 21 def success? !!@success end |