# frozen_string_literal: true module Renderable extend ActiveSupport::Concern def render_success(data = nil, status = :ok, meta = {}) body = { success: true } body[:data] = data if data body[:meta] = meta if meta.present? render json: body, status: end def render_error(message, status = :unprocessable_entity, details: nil) body = { success: false, error: { message: } } body[:error][:details] = details if details.present? render json: body, status: end end