Class: SlackChatter::Response
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- SlackChatter::Response
- Defined in:
- lib/slack_chatter/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 |
# File 'lib/slack_chatter/response.rb', line 7 def initialize response parsed_res = JSON.parse(response.body) super(parsed_res) self.response = response self.code = response.code end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/slack_chatter/response.rb', line 5 def response @response end |
Instance Method Details
#failed? ⇒ Boolean
26 27 28 |
# File 'lib/slack_chatter/response.rb', line 26 def failed? !parsed_res["ok"] end |
#success? ⇒ Boolean
22 23 24 |
# File 'lib/slack_chatter/response.rb', line 22 def success? parsed_res["ok"] end |
#to_h ⇒ Object
14 15 16 |
# File 'lib/slack_chatter/response.rb', line 14 def to_h marshal_dump.with_indifferent_access end |
#to_json ⇒ Object
18 19 20 |
# File 'lib/slack_chatter/response.rb', line 18 def to_json JSON.dump(to_h) end |