Class: Typed::Builder::SumType
- Inherits:
-
Object
- Object
- Typed::Builder::SumType
- Includes:
- BaseType
- Defined in:
- lib/typed/builder.rb
Instance Method Summary collapse
-
#initialize(type_a, type_b) ⇒ SumType
constructor
A new instance of SumType.
- #process(value) ⇒ Object
Methods included from BaseType
#call, #constrained, #constructor, #default, #enum, #instance, #missable, #nullable, #|
Constructor Details
#initialize(type_a, type_b) ⇒ SumType
Returns a new instance of SumType.
186 187 188 189 |
# File 'lib/typed/builder.rb', line 186 def initialize(type_a, type_b) @type_a = type_a @type_b = type_b end |
Instance Method Details
#process(value) ⇒ Object
191 192 193 194 195 196 |
# File 'lib/typed/builder.rb', line 191 def process(value) result = type_a.process(value) return result if result.ok type_b.process(value) end |