-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
attached_class.rb
41 lines (34 loc) 路 848 Bytes
/
attached_class.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
# typed: true
module T::Types
# Modeling AttachedClass properly at runtime would require additional
# tracking, so at runtime we permit all values and rely on the static checker.
# As AttachedClass is modeled statically as a type member on every singleton
# class, this is consistent with the runtime behavior for all type members.
class AttachedClassType < Base
def initialize(); end
def build_type
nil
end
# overrides Base
def name
"T.attached_class"
end
# overrides Base
def valid?(obj)
true
end
# overrides Base
private def subtype_of_single?(other)
case other
when AttachedClassType
true
else
false
end
end
module Private
INSTANCE = AttachedClassType.new.freeze
end
end
end