Class: Rest::BaseWrapper
- Inherits:
-
Object
- Object
- Rest::BaseWrapper
- Defined in:
- lib/rest/wrappers/base_wrapper.rb
Direct Known Subclasses
Wrappers::ExconWrapper, Wrappers::InternalClientWrapper, Wrappers::NetHttpPersistentWrapper, Wrappers::RestClientWrapper, Wrappers::TyphoeusWrapper
Instance Method Summary collapse
-
#close ⇒ Object
if wrapper has a close/shutdown, override this.
- #post_file(url, req_hash = {}) ⇒ Object
-
#to_json_parts(h) ⇒ Object
if body is a hash, it will convert it to json.
Instance Method Details
#close ⇒ Object
if wrapper has a close/shutdown, override this
33 34 35 |
# File 'lib/rest/wrappers/base_wrapper.rb', line 33 def close end |
#post_file(url, req_hash = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rest/wrappers/base_wrapper.rb', line 5 def post_file(url, req_hash={}) response = nil begin if req_hash[:body] req_hash = req_hash.merge(req_hash[:body]) req_hash.delete(:body) end headers = {} if req_hash[:headers] headers = req_hash[:headers] req_hash.delete(:headers) end r2 = Rest::InternalClient.post(url, req_hash, headers) response = Rest::Wrappers::InternalClientResponseWrapper.new(r2) rescue Rest::InternalClient::Exception => ex raise Rest::Wrappers::InternalClientExceptionWrapper.new(ex) end response end |
#to_json_parts(h) ⇒ Object
if body is a hash, it will convert it to json
28 29 30 |
# File 'lib/rest/wrappers/base_wrapper.rb', line 28 def to_json_parts(h) h[:body] = h[:body].to_json if h[:body] && h[:body].is_a?(Hash) end |