Module: Dry::Types::Type
- Included in:
- Composition, Constrained, Default, Enum, Lax, Maybe, Nominal, Schema::Key
- Defined in:
- lib/dry/types/type.rb
Overview
Common Type module denoting an object is a Type
Instance Method Summary collapse
-
#call(input = Undefined, &block) ⇒ Object
(also: #[])
Apply type to a value.
-
#valid?(input = Undefined) ⇒ Boolean
(also: #===)
private
Whether a value is a valid member of the type.
Instance Method Details
#call(input = Undefined) ⇒ Object #call(input = Undefined) {|output| ... } ⇒ Object Also known as: []
Apply type to a value
43 44 45 46 47 48 49 |
# File 'lib/dry/types/type.rb', line 43 def call(input = Undefined, &block) if block_given? call_safe(input, &block) else call_unsafe(input) end end |
#valid?(input = Undefined) ⇒ Boolean Also known as: ===
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether a value is a valid member of the type
18 19 20 21 |
# File 'lib/dry/types/type.rb', line 18 def valid?(input = Undefined) call_safe(input) { return false } true end |