price-point-api/app/controllers/concerns/renderable.rb
Mohammad Kanaan ed626b5066 WIP 2
2026-06-10 19:16:28 +03:00

19 lines
502 B
Ruby

# 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