Sha256: ae6ade73f9bb2cb1bcf3fb95353c09b3a33cf347eefffe3b680c8cab057c9eed

Contents?: true

Size: 572 Bytes

Versions: 3

Compression:

Stored size: 572 Bytes

Contents

module Morpheus
  module ResponseParsing

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods

      def response_from_request(request, metadata)
        ResponseParser.parse(self, request, metadata)
      end

    end

    def build_from_response(response)
      content = Yajl::Parser.parse(response.body)['content']
      if content.keys.include?('type')
        content['type'].constantize.new.merge_attributes(content)
      else
        merge_attributes(content)
      end
    end
    private :build_from_response

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
morpheus-0.3.9 lib/morpheus/mixins/response_parsing.rb
morpheus-0.3.8 lib/morpheus/mixins/response_parsing.rb
morpheus-0.3.7 lib/morpheus/mixins/response_parsing.rb