Sha256: 57fc1b57945cf3dd1c1e6fcaa11a64d50ba7c84d48865afad257fca97988541e

Contents?: true

Size: 484 Bytes

Versions: 5

Compression:

Stored size: 484 Bytes

Contents

require 'delegate'
require 'multi_xml'

module Vacuum
  # A wrapper around the Amazon Product Advertising API response.
  class Response < SimpleDelegator
    class << self
      attr_accessor :parser
    end

    def parser
      @parser || self.class.parser
    end

    attr_writer :parser

    def parse
      parser ? parser.parse(body) : to_h
    end

    def to_h
      MultiXml.parse(body)
    end

    def body
      __getobj__.body.force_encoding('UTF-8')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vacuum-1.5.0 lib/vacuum/response.rb
vacuum-1.4.1 lib/vacuum/response.rb
vacuum-1.4.0 lib/vacuum/response.rb
vacuum-1.3.0 lib/vacuum/response.rb
vacuum-1.2.0 lib/vacuum/response.rb