def consume!(model, options={})
      content_type = request.content_type

      format = Mime::Type.lookup(content_type).try(:symbol) or raise UnsupportedMediaType.new("Cannot consume unregistered media type '#{content_type.inspect}'")

      parsing_method = compute_parsing_method(format)
      representer = prepare_model_for(format, model, options)

      representer.send(parsing_method, incoming_string, options) # e.g. from_json("...")
      model
    end
def consume!(model, options={})
      content_type = request.content_type

      format = Mime::Type.lookup(content_type).try(:symbol) or raise UnsupportedMediaType.new("Cannot consume unregistered media type '#{content_type.inspect}'")

      parsing_method = compute_parsing_method(format)
      representer = prepare_model_for(format, model, options)

      representer.send(parsing_method, incoming_string, options) # e.g. from_json("...")
      model
    end
TODO: move into separate class so we don't pollute controller.