Module: JsonApiResponders::Responder::Sanitizers

Defined in:
lib/json_api_responders/responder/sanitizers.rb

Class Method Summary collapse

Class Method Details

.status(status) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/json_api_responders/responder/sanitizers.rb', line 4

def self.status(status)
  if status.is_a?(Integer)
    status = Rack::Utils::SYMBOL_TO_STATUS_CODE.invert[status]
  end

  if status.nil? || !status.is_a?(Symbol) ||
     Rack::Utils::SYMBOL_TO_STATUS_CODE[status].nil?
    raise(Errors::UnknownHTTPStatus, status)
  end

  status
end