Sha256: 9931055bfa983dd4e0fe111bf6d964374c28427d368bdac55ce9d2e0ab0e8671
Contents?: true
Size: 602 Bytes
Versions: 47
Compression:
Stored size: 602 Bytes
Contents
require "cobrato/exception" module Cobrato RequestTimeout = Class.new(Exception) RequestError = Class.new(Exception) class Response < SimpleDelegator def resolve!(&block) if success? #TODO: test redirect if need block_given? ? yield(self) : self elsif timed_out? timeout! else error! end end private def timeout! raise RequestTimeout end def error! raise RequestError.new( code: code, message: status_message, body: (MultiJson.load(body) rescue {}) ) end end end
Version data entries
47 entries across 47 versions & 1 rubygems