Class: Dry::Types::Lax
- Inherits:
-
Object
- Object
- Dry::Types::Lax
- Defined in:
- lib/dry/types/lax.rb
Overview
Lax types rescue from type-related errors when constructors fail
Instance Attribute Summary
Attributes included from Decorator
Attributes included from Options
Instance Method Summary collapse
- #call(input) ⇒ Object (also: #[], #call_safe, #call_unsafe)
- #lax ⇒ Lax
- #to_ast(meta: true) ⇒ Object
- #try(input, &block) {|failure| ... } ⇒ Result, Logic::Result
Methods included from Printable
Methods included from Builder
#&, #>, #constrained, #constrained_type, #constructor, #constructor_type, #default, #enum, #fallback, #maybe, #optional, #|
Methods included from Decorator
#constrained?, #default?, #initialize, #respond_to_missing?, #to_proc
Methods included from Options
Methods included from Type
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dry::Types::Decorator
Instance Method Details
#call(input) ⇒ Object Also known as: [], call_safe, call_unsafe
22 23 24 |
# File 'lib/dry/types/lax.rb', line 22 def call(input) type.call_safe(input) { |output = input| output } end |
#to_ast(meta: true) ⇒ Object
45 46 47 |
# File 'lib/dry/types/lax.rb', line 45 def to_ast(meta: true) [:lax, type.to_ast(meta: )] end |
#try(input, &block) {|failure| ... } ⇒ Result, Logic::Result
38 39 40 |
# File 'lib/dry/types/lax.rb', line 38 def try(input, &block) type.try(input, &block) end |