typ 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/typ.rb +27 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0f29f7c51d7e758efd8a0d5aa3ff2df8c3bd67f090eb85d7aa9f8e0d8856bd3
|
4
|
+
data.tar.gz: 31233ba93d6e965dd3cbcbb9aac0d887d43c826b9fb859282906e40167642c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e04787c558ca19a07774e8e8e5d1b16e89af45f5a9e82a72fdafbcdd2dfc69efead9215b4c29610df33949b4873f8c7258c9aa9fe584c613185951377cdfd5
|
7
|
+
data.tar.gz: f50128054edf6eedd8974e5bd704416ada9e48dd3f4bf006d1c5b549ce5a5806bf5ee998ffb3e41dd24a57a5d79158efa1f965164902a3bcb96c19b72a2cf863
|
data/lib/typ.rb
CHANGED
@@ -23,7 +23,7 @@ module Typ
|
|
23
23
|
def is type
|
24
24
|
case type
|
25
25
|
when Array
|
26
|
-
gates << Is::Array
|
26
|
+
gates << Is::Array.new(type)
|
27
27
|
when Class
|
28
28
|
if type.include? Typ
|
29
29
|
gates << type
|
@@ -36,8 +36,12 @@ module Typ
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
module Is
|
40
|
+
def self.included gate
|
41
|
+
gate.extend Singleton
|
42
|
+
end
|
43
|
+
|
44
|
+
module Singleton
|
41
45
|
attr_accessor :check
|
42
46
|
end
|
43
47
|
|
@@ -49,9 +53,9 @@ module Typ
|
|
49
53
|
@ok
|
50
54
|
end
|
51
55
|
|
52
|
-
|
56
|
+
module Array
|
53
57
|
class << self
|
54
|
-
def
|
58
|
+
def new array
|
55
59
|
check = if array[0].is_a?(Symbol)
|
56
60
|
method, *arguments = array
|
57
61
|
-> receiver { receiver.send method, *arguments }
|
@@ -62,11 +66,28 @@ module Typ
|
|
62
66
|
fail "not sure how to handle #{array} yet"
|
63
67
|
end
|
64
68
|
|
65
|
-
gate = Class.new
|
69
|
+
gate = Class.new
|
70
|
+
|
71
|
+
gate.include Is
|
66
72
|
gate.check = check
|
73
|
+
|
74
|
+
gate.include self
|
75
|
+
gate.array = array
|
67
76
|
gate
|
68
77
|
end
|
69
78
|
end
|
79
|
+
|
80
|
+
def self.included gate
|
81
|
+
gate.extend Singleton
|
82
|
+
end
|
83
|
+
|
84
|
+
module Singleton
|
85
|
+
attr_accessor :array
|
86
|
+
end
|
87
|
+
|
88
|
+
def to_a
|
89
|
+
self.class.array
|
90
|
+
end
|
70
91
|
end
|
71
92
|
end
|
72
93
|
end
|