Class: PushBot::Response
- Inherits:
-
Object
- Object
- PushBot::Response
- Extended by:
- Forwardable
- Defined in:
- lib/push_bot/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Did the response complete with an error.
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
-
#json ⇒ Hash, Array
The result of the request as a JSON Object.
Constructor Details
#initialize ⇒ Response
7 8 9 10 11 |
# File 'lib/push_bot/response.rb', line 7 def initialize @raw_response = yield rescue => e @error = e end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/push_bot/response.rb', line 5 def error @error end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
5 6 7 |
# File 'lib/push_bot/response.rb', line 5 def raw_response @raw_response end |
Instance Method Details
#error? ⇒ Boolean
Did the response complete with an error
24 25 26 |
# File 'lib/push_bot/response.rb', line 24 def error? defined?(@error) && @error end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/push_bot/response.rb', line 13 def inspect "#<#{self.class}:#{object_id} @success=#{success?} @json=#{json}>" end |
#json ⇒ Hash, Array
The result of the request as a JSON Object
31 32 33 |
# File 'lib/push_bot/response.rb', line 31 def json @json ||= body.present? ? JSON.parse(body) : {} end |