contracts 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/contracts.rb +9 -1
- metadata +3 -3
data/lib/contracts.rb
CHANGED
@@ -5,6 +5,11 @@ class Class
|
|
5
5
|
include MethodDecorators
|
6
6
|
end
|
7
7
|
|
8
|
+
class Module
|
9
|
+
include MethodDecorators
|
10
|
+
end
|
11
|
+
|
12
|
+
|
8
13
|
# This is the main Contract class. When you write a new contract, you'll
|
9
14
|
# write it as:
|
10
15
|
#
|
@@ -83,7 +88,10 @@ class Contract < Decorator
|
|
83
88
|
# e.g. [Num, String]
|
84
89
|
# TODO account for these errors too
|
85
90
|
return mkerror(false, arg, contract) unless arg.is_a?(Array)
|
86
|
-
|
91
|
+
arg.zip(contract).each do |_arg, _contract|
|
92
|
+
res, info = valid?(_arg, _contract)
|
93
|
+
return mkerror(false, arg, contract) unless res
|
94
|
+
end
|
87
95
|
when Hash
|
88
96
|
# e.g. { :a => Num, :b => String }
|
89
97
|
return mkerror(false, arg, contract) unless arg.is_a?(Hash)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contracts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aditya Bhargava
|