Sha256: fb3ca8c266c0fdc34a04c72353dcece90a84d261abf8b1fb730f7b4241f4a753
Contents?: true
Size: 597 Bytes
Versions: 1
Compression:
Stored size: 597 Bytes
Contents
require 'faraday_middleware/response_middleware' module FaradayMiddleware class ParseOpenfireJson < FaradayMiddleware::ResponseMiddleware dependency do require 'json' unless defined?(::JSON) end define_parser do |body| unless body.strip.empty? parsed = ::JSON.parse body case parsed.keys.length when 0 parsed = [] when 1 parsed = parsed.values.first end if parsed.is_a?(Hash) { data: parsed.symbolize_keys } else { data: parsed } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openfire-ruby-0.1.0 | lib/faraday_middleware/parse_openfire_json.rb |