Class: Pdfmonkey::Adapter
- Inherits:
-
Object
- Object
- Pdfmonkey::Adapter
- Defined in:
- lib/pdfmonkey/adapter.rb
Instance Method Summary collapse
- #call(method, resource) ⇒ Object
-
#initialize(config: Pdfmonkey.configuration) ⇒ Adapter
constructor
A new instance of Adapter.
Constructor Details
#initialize(config: Pdfmonkey.configuration) ⇒ Adapter
Returns a new instance of Adapter.
7 8 9 |
# File 'lib/pdfmonkey/adapter.rb', line 7 def initialize(config: Pdfmonkey.configuration) @config = config end |
Instance Method Details
#call(method, resource) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pdfmonkey/adapter.rb', line 11 def call(method, resource) response = send_request(method, resource) case response when Net::HTTPNoContent then true when Net::HTTPSuccess then extract_attributes(response, resource) else extract_errors(response) end rescue StandardError => e { errors: [e.], status: 'error' } end |