Module: Jsapi::Status
- Defined in:
- lib/jsapi/status.rb,
lib/jsapi/status/base.rb,
lib/jsapi/status/code.rb,
lib/jsapi/status/range.rb,
lib/jsapi/status/default.rb
Overview
Provides classes to deal with response status codes.
Defined Under Namespace
Constant Summary collapse
- DEFAULT =
The default status.
Class.new(Base) do def inspect '#<Jsapi::Status::DEFAULT>' end def match?(_) true end end.new('default', priority: 3)
Class Method Summary collapse
-
.from(value) ⇒ Object
Transforms
valueto an instance of Base.
Class Method Details
.from(value) ⇒ Object
Transforms value to an instance of Base.
Raises an ArgumentError if value could not be transformed.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jsapi/status.rb', line 15 def from(value) return value if value.is_a?(Base) case value&.to_s when nil, 'default' DEFAULT when '1XX', '1xx' Range::INFORMATIONAL when '2XX', '2xx' Range::SUCCESS when '3XX', '3xx' Range::REDIRECTION when '4XX', '4xx' Range::CLIENT_ERROR when '5XX', '5xx' Range::SERVER_ERROR else Code.from(value) end end |