Sha256: a67823f7d3745db0bb34bdecd4f843cefa8c843494884d03d561e77b40ca362e

Contents?: true

Size: 668 Bytes

Versions: 16

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true
require 'active_support/core_ext/hash/conversions'

module Roqua
  module Healthy
    module A19
      class ResponseParser
        attr_reader :response

        def initialize(response)
          @response = response
        end

        def fetch(root)
          parsed_body[root] || {}
        end

        private

        def parsed_body
          # from_xml will throw 'IOError: not modifiable string' without using dup in ActiveSupport 4.*
          @parsed_body ||= Hash.from_xml(response.body.dup)
        rescue REXML::ParseException => e
          raise IllegalMirthResponse, e.message
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roqua-healthy-1.6.0 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.13 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.12 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.11 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.10 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.9 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.8 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.7 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.6 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.5 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.4 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.3 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.2 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.1 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.5.0 lib/roqua/healthy/a19/response_parser.rb
roqua-healthy-1.4.3 lib/roqua/healthy/a19/response_parser.rb