class ApiResponder < ActionController::Responder
  def to_format
    case
      when has_errors?
        logger.debug("REST API entity has error: #{resource.errors.inspect}")
        controller.response.status = :unprocessable_entity
      when post?
        logger.debug("REST API post")
        controller.response.status = :created
    end

    default_render
  rescue ActionView::MissingTemplate => e
    api_behavior(e)
  end
end
