Class: BreezyPDF::Response
- Inherits:
-
Object
- Object
- BreezyPDF::Response
show all
- Defined in:
- lib/breezy_pdf/response.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
6
7
8
9
|
# File 'lib/breezy_pdf/response.rb', line 6
def initialize(http_response)
@http_response = http_response
BreezyPDF.logger.fatal("[BreezyPDF] Network request failed: #{@http_response.body}") if failure?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_blk) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/breezy_pdf/response.rb', line 19
def method_missing(method, *_args, &_blk)
if body.key?(method.to_s)
body[method.to_s]
else
super
end
end
|
Instance Method Details
#failure? ⇒ Boolean
15
16
17
|
# File 'lib/breezy_pdf/response.rb', line 15
def failure?
!success?
end
|
#respond_to_missing?(method) ⇒ Boolean
27
28
29
|
# File 'lib/breezy_pdf/response.rb', line 27
def respond_to_missing?(method, *)
body.key?(method.to_s)
end
|
#success? ⇒ Boolean
11
12
13
|
# File 'lib/breezy_pdf/response.rb', line 11
def success?
code >= 200 && code < 400
end
|