module Dry::Concrete::Extensions::Type
Public Instance Methods
to_constructor()
click to toggle source
# File lib/dry/concrete/extensions/type.rb, line 158 def to_constructor Types.Instance(self) | Types.Constructor(self, method(:new)) end
to_type()
click to toggle source
Converts type references into types
@example A strict string into a type
type = "strict.string".to_type type.valid?("string") # => true type.valid?(:symbol) # => false
@example A (strict) symbol into a type
type = "symbol".to_type type.valid?(:symbol) # => true type.valid?("string") # => false
@return [Dry::Types::Type] @raise [ArgumentError] if the type is not a valid type
# File lib/dry/concrete/extensions/type.rb, line 31 def to_type Dry::Types[self] rescue Dry::Container::Error raise ArgumentError, "Type reference [#{inspect}] not found in Dry::Types" end