type_constraints 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/type_constraints/meta.rb +2 -2
- data/lib/type_constraints/version.rb +1 -1
- data/lib/type_constraints.rb +4 -4
- data/spec/type_constraints_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 144bf38a12b0f75552d47a108880d5a6be122004
|
4
|
+
data.tar.gz: 1ce2a20acb3dcac6773d448e28d85c22bad860ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a6504e27851e39f038426cc5262268715c93e14f4cd53cd3e9b27c836151878c4f9ae874c3f26b26e8b9e49634da19f3e2577abacd53da340493dc3beea384
|
7
|
+
data.tar.gz: deb0d7675960e2a80633a1deff40380d6f1b53f45f5624b1863a08e10d9ce945ab6e81ec2f2b3bd8fe6801d3f683b179012e26b94e0158462d88df48c70916cb
|
data/lib/type_constraints.rb
CHANGED
@@ -7,7 +7,7 @@ module TypeConstraints
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :registry
|
9
9
|
def setup(&code)
|
10
|
-
@registry
|
10
|
+
@registry ||= Registry.new
|
11
11
|
@registry.instance_eval(&code)
|
12
12
|
@registry
|
13
13
|
end
|
@@ -17,9 +17,9 @@ module TypeConstraints
|
|
17
17
|
registry.metas[name].check?(val)
|
18
18
|
end
|
19
19
|
|
20
|
-
def check!(name, val)
|
21
|
-
raise Exceptions::MissingMeta if registry.metas[name].nil?
|
22
|
-
registry.metas[name].check!(val)
|
20
|
+
def check!(name, val, level=1)
|
21
|
+
raise Exceptions::MissingMeta, nil, caller(level) if registry.metas[name].nil?
|
22
|
+
registry.metas[name].check!(val, level+1)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -65,4 +65,10 @@ describe TypeConstraints do
|
|
65
65
|
expect { TypeConstraints.check!(:Hoge, [100, 200]) }.to raise_error(TypeConstraints::Exceptions::MissingMeta)
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
describe "having default types" do
|
70
|
+
it "having :String" do
|
71
|
+
expect(TypeConstraints.check?(:String, "test")).to eq true
|
72
|
+
end
|
73
|
+
end
|
68
74
|
end
|