Class: Dry::Types::AnyClass
Overview
Any is a nominal type that defines Object as the primitive class
This type is useful in places where you can’t be specific about the type and anything is acceptable.
Constant Summary
Constants inherited from Nominal
Instance Attribute Summary
Attributes inherited from Nominal
Attributes included from Options
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**options) ⇒ AnyClass
constructor
private
A new instance of AnyClass.
- #name ⇒ String
- #to_ast(meta: true) ⇒ Array
- #with(**new_options) ⇒ Type
Methods inherited from Nominal
[], #call_safe, #call_unsafe, #coerce, #constrained?, #default?, #failure, #lax, #optional?, #primitive?, #success, #to_proc, #try, #try_coerce
Methods included from Printable
Methods included from Builder
#&, #>, #constrained, #constrained_type, #constructor, #constructor_type, #default, #enum, #fallback, #lax, #maybe, #optional, #|
Methods included from Meta
Methods included from Type
Constructor Details
#initialize(**options) ⇒ AnyClass
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.
Returns a new instance of AnyClass.
17 18 19 |
# File 'lib/dry/types/any.rb', line 17 def initialize(**) super(::Object, **) end |
Class Method Details
.name ⇒ Object
12 13 14 |
# File 'lib/dry/types/any.rb', line 12 def self.name "Any" end |
Instance Method Details
#name ⇒ String
24 25 26 |
# File 'lib/dry/types/any.rb', line 24 def name "Any" end |
#to_ast(meta: true) ⇒ Array
40 41 42 |
# File 'lib/dry/types/any.rb', line 40 def to_ast(meta: true) [:any, ? self. : EMPTY_HASH] end |
#with(**new_options) ⇒ Type
33 34 35 |
# File 'lib/dry/types/any.rb', line 33 def with(**) self.class.new(**, meta: @meta, **) end |