class Facile::Response::Wrapper
Attributes
body[R]
headers[R]
Public Class Methods
new(body, headers = {})
click to toggle source
# File lib/facile/response/wrapper.rb, line 12 def initialize(body, headers = {}) @body, @headers = body, headers end
parse(body, options = {})
click to toggle source
# File lib/facile/response/wrapper.rb, line 6 def self.parse(body, options = {}) wrapper = new(body, options) wrapper.parse end
Public Instance Methods
content_type_to_class(content_type)
click to toggle source
# File lib/facile/response/wrapper.rb, line 30 def content_type_to_class(content_type) case content_type when /application\/json/ 'Json' else 'Raw' end end
parse()
click to toggle source
# File lib/facile/response/wrapper.rb, line 16 def parse wrapper = "Raw" if headers.has_key?('content-type') wrapper = content_type_to_class(headers['content-type']) end klass = "Facile::Response::Wrapper::#{wrapper}".split('::').inject(Object) do |o, c| o.const_get(c) end klass.new(@body).parsed_body end