Sha256: 3940f04c22913f072aa4462a224ab6d7fb6274fd73713f0296f02f43174a46b0

Contents?: true

Size: 616 Bytes

Versions: 165

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true
# typed: true

module T::Private::Types
  # Wraps a proc for a type alias to defer its evaluation.
  class TypeAlias < T::Types::Base

    def initialize(callable)
      @callable = callable
    end

    def build_type
      nil
    end

    def aliased_type
      @aliased_type ||= T::Utils.coerce(@callable.call)
    end

    # overrides Base
    def name
      aliased_type.name
    end

    # overrides Base
    def recursively_valid?(obj)
      aliased_type.recursively_valid?(obj)
    end

    # overrides Base
    def valid?(obj)
      aliased_type.valid?(obj)
    end
  end
end

Version data entries

165 entries across 165 versions & 1 rubygems

Version Path
sorbet-runtime-0.5.11668 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11663 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11647 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11645 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11642 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11641 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11637 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11635 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11633 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11631 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11630 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11625 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11620 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11618 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11615 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11611 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11610 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11609 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11608 lib/types/private/types/type_alias.rb
sorbet-runtime-0.5.11604 lib/types/private/types/type_alias.rb