Sha256: 0aee0d578a2e3196c03087ae69bdd330c35ecb243d7a86668c0f4bcefcbfaec1
Contents?: true
Size: 712 Bytes
Versions: 5
Compression:
Stored size: 712 Bytes
Contents
require 'oj' require 'ox' require 'dagger/ox_extension' class Parsers def initialize(response) if type = response.content_type @normalized_type = type.split(';').first.gsub(/[^a-z]/, '_') @body = response.body end end def process send(@normalized_type, @body) if @normalized_type && respond_to?(@normalized_type) end def application_json(body) Oj.load(body) rescue Oj::ParseError nil end alias_method :text_javascript, :application_json alias_method :application_x_javascript, :application_json def text_xml(body) if res = Ox.parse(body) res.to_hash end rescue Ox::ParseError nil end alias_method :application_xml, :text_xml end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
dagger-1.7.1 | lib/dagger/parsers.rb |
dagger-1.7.0 | lib/dagger/parsers.rb |
dagger-1.6.2 | lib/dagger/parsers.rb |
dagger-1.6.1 | lib/dagger/parsers.rb |
dagger-1.5.1 | lib/dagger/parsers.rb |