Class: SlackChatter::Response

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/slack_chatter/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/slack_chatter/response.rb', line 26

def failed?
  !parsed_res["ok"]
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/slack_chatter/response.rb', line 22

def success?
  parsed_res["ok"]
end

#to_hObject



14
15
16
# File 'lib/slack_chatter/response.rb', line 14

def to_h
  marshal_dump.with_indifferent_access
end

#to_jsonObject



18
19
20
# File 'lib/slack_chatter/response.rb', line 18

def to_json
  JSON.dump(to_h)
end