Module: ActionFigure::Formatters::Default
Overview
Rails-style responses with { data: } envelope
Constant Summary
ActionFigure::Formatter::REQUIRED_METHODS
Instance Method Summary
collapse
#NoContent
#Conflict, #Forbidden, #Gone, #Locked, #NotFound, #PaymentRequired, #UnavailableForLegalReasons, #UnprocessableContent
Instance Method Details
#Accepted(resource: nil, meta: nil) ⇒ ActionFigure::response
22
23
24
25
26
|
# File 'lib/action_figure/formatters/default.rb', line 22
def Accepted(resource: nil, meta: nil)
body = { data: resource }
body[:meta] = meta if meta
{ json: body, status: :accepted }
end
|
#Created(resource:, meta: nil) ⇒ ActionFigure::response
16
17
18
19
20
|
# File 'lib/action_figure/formatters/default.rb', line 16
def Created(resource:, meta: nil)
body = { data: resource }
body[:meta] = meta if meta
{ json: body, status: :created }
end
|
#error_response(errors:, status:) ⇒ ActionFigure::response
28
29
30
|
# File 'lib/action_figure/formatters/default.rb', line 28
def error_response(errors:, status:)
{ json: { errors: errors }, status: status }
end
|
#Ok(resource:, meta: nil) ⇒ ActionFigure::response
10
11
12
13
14
|
# File 'lib/action_figure/formatters/default.rb', line 10
def Ok(resource:, meta: nil)
body = { data: resource }
body[:meta] = meta if meta
{ json: body, status: :ok }
end
|