Class: PushBot::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/push_bot/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse



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

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/push_bot/response.rb', line 5

def error
  @error
end

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

#inspectObject



13
14
15
# File 'lib/push_bot/response.rb', line 13

def inspect
  "#<#{self.class}:#{object_id} @success=#{success?} @json=#{json}>"
end

#jsonHash, 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