Sha256: ca43b5bc43916720e5563e962b60a65a81d55869e405f091e8c49fceba368249

Contents?: true

Size: 391 Bytes

Versions: 5

Compression:

Stored size: 391 Bytes

Contents

module Moip2
  class Response < SimpleDelegator
    def initialize(resp, json)
      if json.is_a? Hash
        super(RecursiveOpenStruct.new(json, recurse_over_arrays: true))
      else
        super(resp)
      end
      @resp = resp
    end

    def success?
      (200..299).cover? @resp.code.to_i
    end

    def client_error?
      (400..499).cover? @resp.code.to_i
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
moip2-1.3.1 lib/moip2/response.rb
moip2-1.2.1 lib/moip2/response.rb
moip2-1.2.0 lib/moip2/response.rb
moip2-1.1.0 lib/moip2/response.rb
moip2-1.0.0 lib/moip2/response.rb