Sha256: a8163463da907b1d3c213bd1f2d9f66efe81b93e85778e5a55c7b5b037f0383d

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

module Mixture
  module Types
    # A class type.  This can be subtyped, and is subtyped for
    # non-primitive classes.
    class Class < Object
      register
      options[:primitive] = ::Class
      options[:noinfer]   = true
      options[:members]   = [Object]
      options[:method]    = :to_class
      options[:types]     = ThreadSafe::Cache.new
      extend Access

      constraints.clear
      # rubocop:disable Style/CaseEquality
      constraint do |value|
        if value.is_a?(::Class)
          options.fetch(:members).first == value
        else
          options.fetch(:members).first === value
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixture-0.7.1 lib/mixture/types/class.rb
mixture-0.7.0 lib/mixture/types/class.rb