Top Level Namespace

Defined Under Namespace

Modules: Actions, Culpa, CulpaHelpers Classes: Action, FileStreamer, RendererDescriber, Session

Constant Summary collapse

CULPA_VERSION =
'2.1.1'.freeze

Instance Method Summary collapse

Instance Method Details

#jsonObject

This renderer helps render a JSON. You can add a or_status: :status_code to the render json: … to render a status code if the passed object to render is nil.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/culpa/renderers/json.rb', line 7

describe_renderer :json do |options, _envelope|
  if options[:json]
    {
      format: :json,
      status: RETURN_CODES[options[:status]] || 200,
      headers: { 'Content-Type' => 'application/json' }.merge(options[:headers]),
      object: options[:json]
    }
  else
    {
      format: :status,
      headers: options[:headers],
      status: RETURN_CODES[options[:or_status]]
    }
  end
end

#statusObject

This renderer helps to return a simple status code the client



5
6
7
8
9
10
11
# File 'lib/culpa/renderers/status.rb', line 5

describe_renderer :status do |options, _envelope|
  {
    format: :status,
    headers: options[:headers],
    status: RETURN_CODES[options[:status]]
  }
end