Sha256: 4f2fa0d641933132b2ec539dbda5d324b168e6b028d90c805529037b89d759fd
Contents?: true
Size: 550 Bytes
Versions: 6
Compression:
Stored size: 550 Bytes
Contents
require 'oj' require 'ox' require 'dagger/ox_extension' class Parsers def initialize(response) @body = response.body @normalized = response.content_type.to_s.sub('/', '_').split(';').first end def process send(@normalized, @body) if respond_to?(@normalized) end def application_json(body) Oj.load(body) rescue Oj::ParseError nil end alias_method :text_javascript, :application_json def text_xml(body) Ox.parse(body) rescue Ox::ParseError nil end alias_method :application_xml, :text_xml end
Version data entries
6 entries across 6 versions & 1 rubygems