-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathresponse.rb
61 lines (49 loc) · 1.17 KB
/
response.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module DwollaV2
class Response
extend Forwardable
delegate [:to_s, :to_json] => :response_body
def initialize response
@response = response
end
def response_status
@response.status
end
def response_headers
if @response.respond_to? :response_headers
@response.response_headers
elsif @response.respond_to? :headers
@response.headers
end
end
def respond_to? method, include_private = false
super || response_body.respond_to?(method)
end
def is_a? klass
super || response_body.is_a?(klass)
end
def kind_of? klass
super || response_body.kind_of?(klass)
end
def == other
super || response_body == other
end
def method_missing method, *args, &block
if response_body.respond_to? method
response_body.public_send method, *args, &block
else
super
end
end
def inspect
Util.pretty_inspect(
self.class.name,
{ response_status: response_status, response_headers: response_headers },
response_body
)
end
private
def response_body
@response.body
end
end
end