class Restspec::Values::StatusCode
A value object that transforms a http status code (201) or a symbol with the status code message (:created) to a simple number (201).
Attributes
number_or_symbol[RW]
Public Class Methods
new(number_or_symbol)
click to toggle source
# File lib/restspec/values/status_code.rb, line 7 def initialize(number_or_symbol) self.number_or_symbol = number_or_symbol end
Public Instance Methods
value()
click to toggle source
@example
StatusCode.new(201).value # 201 StatusCode.new(:created).value # 201
@return [Fixnum] the status code
# 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