Class: Dry::Types::AnyClass

Inherits:
Nominal
  • Object
show all
Defined in:
lib/dry/types/any.rb

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(**options)
  super(::Object, **options)
end

Instance Attribute Details

#optionsHash (readonly) Originally defined in module Options

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:

Class Method Details

.nameObject



12
13
14
# File 'lib/dry/types/any.rb', line 12

def self.name
  "Any"
end

Instance Method Details

#nameString

Returns:

  • (String)


24
25
26
# File 'lib/dry/types/any.rb', line 24

def name
  "Any"
end

#to_ast(meta: true) ⇒ Array

Returns:



40
41
42
# File 'lib/dry/types/any.rb', line 40

def to_ast(meta: true)
  [:any, meta ? self.meta : EMPTY_HASH]
end

#with(**new_options) ⇒ Type

Parameters:

  • new_options (Hash)

Returns:



33
34
35
# File 'lib/dry/types/any.rb', line 33

def with(**new_options)
  self.class.new(**options, meta: @meta, **new_options)
end