Class: Dry::Data::Type::Optional
Instance Attribute Summary
#constructor, #primitive
Instance Method Summary
collapse
[], #initialize, #name, passthrough_constructor, strict_constructor
Instance Method Details
#call(input) ⇒ Object
9
10
11
|
# File 'lib/dry/data/type/optional.rb', line 9
def call(input)
Maybe(input)
end
|
#valid?(input) ⇒ Boolean
13
14
15
|
# File 'lib/dry/data/type/optional.rb', line 13
def valid?(input)
input.nil? || super
end
|
#|(other) ⇒ Object
5
6
7
|
# File 'lib/dry/data/type/optional.rb', line 5
def |(other)
Data.SumType(self.class.new(constructor, other.primitive), other)
end
|