thingtank 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -16
- data/VERSION +1 -1
- metadata +20 -20
data/README.md
CHANGED
@@ -22,15 +22,6 @@ or in rvm:
|
|
22
22
|
Examples:
|
23
23
|
--------
|
24
24
|
|
25
|
-
To simplify the class building we let them all inherit from a role class
|
26
|
-
|
27
|
-
class Born < ThingTank::Role
|
28
|
-
property :birth_date
|
29
|
-
property :birth_place
|
30
|
-
|
31
|
-
validates_presence_of :birth_date # make sure a date is given
|
32
|
-
end
|
33
|
-
|
34
25
|
Imagine a Caesar is born
|
35
26
|
|
36
27
|
class Born < ThingTank::Role
|
@@ -92,14 +83,14 @@ when he is adult, he wants to marry. now things are getting a bit more complicat
|
|
92
83
|
validate :spouse_should_be_a_person
|
93
84
|
# ensure that 'spouse' is a doc_id of a Person
|
94
85
|
def spouse_should_be_a_person
|
95
|
-
Person.get(self["spouse"]).valid? # loads doc as role Person and validates
|
86
|
+
Person.get(self["spouse"]).valid? # loads doc as role Person and validates, same as ThingTank.get(self["spouse"]).as(Person).valid?
|
96
87
|
end
|
97
88
|
end
|
98
89
|
|
99
90
|
we want easy access to the name of the spouse
|
100
91
|
|
101
92
|
class Spouse < ThingTank::Role
|
102
|
-
property :married # doc must have "married" property (should be of class married)
|
93
|
+
property :married # doc must have "married" property (should be of class married, we don't check this at the moment)
|
103
94
|
property :married_state
|
104
95
|
|
105
96
|
validate :spouse_should_be_married
|
@@ -130,7 +121,7 @@ now we could easily get julius married
|
|
130
121
|
conny = ThingTank.create :gender => "f", :name => 'Cornelia', :roles => ['Person']
|
131
122
|
julius["married"] = {"date" => "84 BC", "spouse" => conny.id}
|
132
123
|
julius["married_state"] = "married"
|
133
|
-
julius.with("married").is(Married).valid? # => true # "married" is a property that plays the
|
124
|
+
julius.with("married").is(Married).valid? # => true # "married" is a property that plays the Married role
|
134
125
|
julius.has(Spouse).valid? # #has is an alias of #is
|
135
126
|
julius.save
|
136
127
|
julius.reload
|
@@ -215,10 +206,9 @@ julius could even marry a second time, i.e. marriage becomes an Array of Marriag
|
|
215
206
|
# ouch, two women!
|
216
207
|
|
217
208
|
|
218
|
-
we should let Spouse know that Marriage might be an array, so simply overwrite marriage with
|
219
209
|
julius is still married with Cornelia but he should not
|
220
210
|
|
221
|
-
if Cornelia died before his second marriage, it
|
211
|
+
if Cornelia died before his second marriage, it would not be a problem:
|
222
212
|
|
223
213
|
class Dead
|
224
214
|
# all callbacks of roles are called and defined like corresponding callbacks of the doc
|
@@ -288,8 +278,8 @@ since julius is immortal, no one should be able to destroy him:
|
|
288
278
|
|
289
279
|
ThingTank.get(id).nil? # => julius is still there
|
290
280
|
|
291
|
-
You may subclass
|
292
|
-
native properties of
|
281
|
+
You may subclass ThingTank to do further separation and mix the
|
282
|
+
native properties of ThingTanks / its subclasses with the roles properties.
|
293
283
|
|
294
284
|
|
295
285
|
Contributing to thingtank
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thingtank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: couchrest
|
16
|
-
requirement: &
|
16
|
+
requirement: &21199960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21199960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: couchrest_model
|
27
|
-
requirement: &
|
27
|
+
requirement: &21198980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21198980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &21198080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *21198080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &21197160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *21197160
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &21196200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *21196200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &21195040 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *21195040
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: linecache19
|
82
|
-
requirement: &
|
82
|
+
requirement: &21188780 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *21188780
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: ruby-debug19
|
93
|
-
requirement: &
|
93
|
+
requirement: &21187380 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *21187380
|
102
102
|
description:
|
103
103
|
email: ! 'Base64.decode64(bGludXhAbWFyY3JlbmVhcm5zLmRl
|
104
104
|
|
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
segments:
|
158
158
|
- 0
|
159
|
-
hash:
|
159
|
+
hash: -648606898342500775
|
160
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.15
|
169
169
|
signing_key:
|
170
170
|
specification_version: 3
|
171
171
|
summary: thin wrapper around couchrest
|