Sha256: 39961b13bf649f89dcc11839a2deac9c0e238a0fbe2a69d42cee404a4ec2287e

Contents?: true

Size: 908 Bytes

Versions: 5

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Types
    # 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.
    #
    # @api public
    class AnyClass < Nominal
      def self.name
        'Any'
      end

      # @api private
      def initialize(**options)
        super(::Object, options)
      end

      # @return [String]
      #
      # @api public
      def name
        'Any'
      end

      # @param [Hash] new_options
      #
      # @return [Type]
      #
      # @api public
      def with(new_options)
        self.class.new(**options, meta: @meta, **new_options)
      end

      # @return [Array]
      #
      # @api public
      def to_ast(meta: true)
        [:any, meta ? self.meta : EMPTY_HASH]
      end
    end

    Any = AnyClass.new
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-types-1.2.0 lib/dry/types/any.rb
dry-types-1.1.1 lib/dry/types/any.rb
dry-types-1.1.0 lib/dry/types/any.rb
dry-types-1.0.1 lib/dry/types/any.rb
dry-types-1.0.0 lib/dry/types/any.rb