class DwollaV2::Error
Public Class Methods
new(response)
click to toggle source
# File lib/dwolla_v2/error.rb, line 19 def initialize response @response = response end
raise!(response)
click to toggle source
# File lib/dwolla_v2/error.rb, line 8 def self.raise! response unless response.respond_to? :body response = turn_into_response(response) end if response.body.is_a?(Hash) && klass = error_class(response.body[:error] || response.body[:code]) raise klass, response, caller else raise self, response, caller end end
Private Class Methods
error_class(error_code)
click to toggle source
# File lib/dwolla_v2/error.rb, line 75 def self.error_class error_code DwollaV2.const_get "#{Util.classify(error_code).chomp("Error")}Error" rescue false end
turn_into_response(response)
click to toggle source
# File lib/dwolla_v2/error.rb, line 69 def self.turn_into_response response OpenStruct.new status: nil, headers: nil, body: Util.deep_super_hasherize(Util.deep_parse_iso8601_values response) end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/dwolla_v2/error.rb, line 43 def == other super || response_body == other end
headers()
click to toggle source
# File lib/dwolla_v2/error.rb, line 23 def headers if @response.respond_to? :response_headers @response.response_headers elsif @response.respond_to? :headers @response.headers end end
inspect()
click to toggle source
# File lib/dwolla_v2/error.rb, line 63 def inspect Util.pretty_inspect self.class.name, { status: status, headers: headers }, response_body end
is_a?(klass)
click to toggle source
Calls superclass method
# File lib/dwolla_v2/error.rb, line 35 def is_a? klass super || response_body.is_a?(klass) end
kind_of?(klass)
click to toggle source
Calls superclass method
# File lib/dwolla_v2/error.rb, line 39 def kind_of? klass super || response_body.kind_of?(klass) end
message()
click to toggle source
# File lib/dwolla_v2/error.rb, line 55 def message to_s end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/dwolla_v2/error.rb, line 47 def method_missing method, *args, &block if response_body.respond_to? method response_body.public_send method, *args, &block else super end end
respond_to?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/dwolla_v2/error.rb, line 31 def respond_to? method, include_private = false super || response_body.respond_to?(method) end
to_str()
click to toggle source
# File lib/dwolla_v2/error.rb, line 59 def to_str nil end
Private Instance Methods
response_body()
click to toggle source
# File lib/dwolla_v2/error.rb, line 79 def response_body @response.body end