Class: Restspec::Values::StatusCode
- Inherits:
-
Object
- Object
- Restspec::Values::StatusCode
- Defined in:
- lib/restspec/values/status_code.rb
Overview
A value object that transforms a http status code (201) or a symbol with the status code message (:created) to a simple number (201).
Instance Method Summary collapse
-
#initialize(number_or_symbol) ⇒ StatusCode
constructor
A new instance of StatusCode.
-
#value ⇒ Fixnum
The status code.
Constructor Details
#initialize(number_or_symbol) ⇒ StatusCode
Returns a new instance of StatusCode.
7 8 9 |
# File 'lib/restspec/values/status_code.rb', line 7 def initialize(number_or_symbol) self.number_or_symbol = number_or_symbol end |
Instance Method Details
#value ⇒ Fixnum
Returns the status code.
15 16 17 18 19 20 21 |
# File 'lib/restspec/values/status_code.rb', line 15 def value if number_or_symbol.is_a?(Symbol) Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(number_or_symbol) else number_or_symbol end end |