Class: Code42Api::BaseResponder

Inherits:
ActionController::Responder
  • Object
show all
Defined in:
lib/code42_api/base_responder.rb

Instance Method Summary collapse

Instance Method Details

#api_behavior(error) ⇒ Object

Raises:

  • (MissingRenderer)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/code42_api/base_responder.rb', line 4

def api_behavior(error)
  raise error unless resourceful?
  raise MissingRenderer.new(format) unless has_renderer?

  if get?
    display resource
  elsif post?
    display resource, status: :created, location: api_location
  elsif put? || patch?
    display resource, status: :ok
  else
    head :no_content
  end
end