Sha256: 4a6e3dbff62a868f299e272c21a4149ebb81670cfdf37d457aa7d684e6284445
Contents?: true
Size: 967 Bytes
Versions: 1
Compression:
Stored size: 967 Bytes
Contents
# ApiClient::Parser provides a method to parse the request response. module ApiClient::Parser # Parse the JSON response. # # @param [HTTP] response HTTP object for the request. # @return [Array] the code and the body parsed. def _response(response) begin object = JSON.parse(response.body) object = object[remote_object] if object.key?(remote_object) object = object[remote_object.pluralize] if object.key?(remote_object.pluralize) rescue JSON::ParserError object = nil end return response.code, object end # Return the Remote Object Name. # # @return [String] a string with the remote object class name. def remote_object @remote_object.blank? ? self.to_s.split('::').last.downcase : @remote_object end # Set a custom remote object name instead of the virtual class name. # # @param [String] remote_object name. def remote_object=(remote_object) @remote_object = remote_object end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api-client-1.5.0 | lib/api-client/parser.rb |