contracts 0.0.9 → 0.1.0
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.
- data/lib/contracts.rb +11 -16
- data/lib/foo.rb +4 -9
- metadata +3 -3
data/lib/contracts.rb
CHANGED
@@ -2,12 +2,21 @@ require 'decorators'
|
|
2
2
|
require 'builtin_contracts'
|
3
3
|
module Contracts
|
4
4
|
def self.included(base)
|
5
|
-
base
|
5
|
+
common base
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.extended(base)
|
9
|
-
base
|
9
|
+
common base
|
10
10
|
end
|
11
|
+
|
12
|
+
def self.common base
|
13
|
+
base.extend MethodDecorators
|
14
|
+
base.class_eval do
|
15
|
+
def Contract(*args)
|
16
|
+
self.class.Contract(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
# This is the main Contract class. When you write a new contract, you'll
|
@@ -206,17 +215,3 @@ class Contract < Decorator
|
|
206
215
|
end
|
207
216
|
end
|
208
217
|
end
|
209
|
-
|
210
|
-
# convenience function for small scripts.
|
211
|
-
# Use as:
|
212
|
-
#
|
213
|
-
# use_contracts self
|
214
|
-
#
|
215
|
-
# And then you can use contracts on functions
|
216
|
-
# that aren't in any module or class.
|
217
|
-
def use_contracts(this)
|
218
|
-
this.class.send(:include, Contracts)
|
219
|
-
def this.Contract(*args)
|
220
|
-
self.class.Contract(*args)
|
221
|
-
end
|
222
|
-
end
|
data/lib/foo.rb
CHANGED
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.9
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aditya Bhargava
|