lib/moip2/response.rb in moip2-0.1.4 vs lib/moip2/response.rb in moip2-1.0.0

- old
+ new

@@ -1,20 +1,20 @@ module Moip2 - class Response < SimpleDelegator - def initialize(resp, json) - super(RecursiveOpenStruct.new(json, :recurse_over_arrays => true)) + if json.is_a? Hash + super(RecursiveOpenStruct.new(json, recurse_over_arrays: true)) + else + super(resp) + end @resp = resp end def success? - (200..299).include? @resp.code.to_i + (200..299).cover? @resp.code.to_i end def client_error? - (400..499).include? @resp.code.to_i + (400..499).cover? @resp.code.to_i end - end - end