Module: Stoplight::Types
- Defined in:
- lib/stoplight/types.rb
Class Method Summary collapse
-
.must(value) ⇒ T
Asserts a value is non-nil, returning it with a narrowed type.
- .undefined ⇒ Object
Class Method Details
.must(value) ⇒ T
Asserts a value is non-nil, returning it with a narrowed type.
Use this to satisfy Steep’s flow typing when you know a nilable value must be present. Prefer this over type assertions (#: Type) since it provides runtime validation.
21 22 23 24 25 26 27 |
# File 'lib/stoplight/types.rb', line 21 def self.must(value) if value.nil? raise TypeError, "must not have nil value" else value end end |
.undefined ⇒ Object
7 |
# File 'lib/stoplight/types.rb', line 7 def self.undefined = Undefined.instance |