deep_cloneable 2.3.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +12 -14
- data/CHANGELOG.md +157 -1
- data/Gemfile +7 -11
- data/Gemfile.lock +7 -55
- data/LICENSE +1 -1
- data/Rakefile +5 -19
- data/deep_cloneable.gemspec +18 -70
- data/init.rb +3 -1
- data/lib/deep_cloneable/association_not_found_exception.rb +6 -0
- data/lib/deep_cloneable/deep_clone.rb +207 -0
- data/lib/deep_cloneable/skip_validations.rb +10 -0
- data/lib/deep_cloneable/version.rb +3 -0
- data/lib/deep_cloneable.rb +12 -195
- data/readme.md +113 -18
- metadata +15 -36
- data/.document +0 -5
- data/.travis.yml +0 -102
- data/VERSION +0 -1
- data/gemfiles/3.1.gemfile +0 -20
- data/gemfiles/3.1.gemfile.lock +0 -86
- data/gemfiles/3.2.gemfile +0 -17
- data/gemfiles/3.2.gemfile.lock +0 -86
- data/gemfiles/4.0.gemfile +0 -17
- data/gemfiles/4.0.gemfile.lock +0 -93
- data/gemfiles/4.1.gemfile +0 -17
- data/gemfiles/4.1.gemfile.lock +0 -93
- data/gemfiles/4.2.gemfile +0 -17
- data/gemfiles/4.2.gemfile.lock +0 -91
- data/gemfiles/5.0.gemfile +0 -16
- data/gemfiles/5.0.gemfile.lock +0 -91
- data/gemfiles/5.1.gemfile +0 -16
- data/gemfiles/5.1.gemfile.lock +0 -91
- data/gemfiles/5.2.gemfile +0 -15
- data/gemfiles/5.2.gemfile.lock +0 -91
- data/test/database.yml +0 -6
- data/test/models.rb +0 -142
- data/test/schema.rb +0 -146
- data/test/test_deep_cloneable.rb +0 -476
- data/test/test_helper.rb +0 -36
data/gemfiles/4.2.gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (4.2.10)
|
5
|
-
activesupport (= 4.2.10)
|
6
|
-
builder (~> 3.1)
|
7
|
-
activerecord (4.2.10)
|
8
|
-
activemodel (= 4.2.10)
|
9
|
-
activesupport (= 4.2.10)
|
10
|
-
arel (~> 6.0)
|
11
|
-
activesupport (4.2.10)
|
12
|
-
i18n (~> 0.7)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
addressable (2.4.0)
|
17
|
-
appraisal (2.2.0)
|
18
|
-
bundler
|
19
|
-
rake
|
20
|
-
thor (>= 0.14.0)
|
21
|
-
arel (6.0.4)
|
22
|
-
builder (3.2.3)
|
23
|
-
descendants_tracker (0.0.4)
|
24
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
25
|
-
faraday (0.9.2)
|
26
|
-
multipart-post (>= 1.2, < 3)
|
27
|
-
git (1.2.9.1)
|
28
|
-
github_api (0.16.0)
|
29
|
-
addressable (~> 2.4.0)
|
30
|
-
descendants_tracker (~> 0.0.4)
|
31
|
-
faraday (~> 0.8, < 0.10)
|
32
|
-
hashie (>= 3.4)
|
33
|
-
mime-types (>= 1.16, < 3.0)
|
34
|
-
oauth2 (~> 1.0)
|
35
|
-
hashie (3.5.7)
|
36
|
-
highline (1.6.21)
|
37
|
-
i18n (0.7.0)
|
38
|
-
jeweler (2.1.1)
|
39
|
-
builder
|
40
|
-
bundler (>= 1.0)
|
41
|
-
git (>= 1.2.5)
|
42
|
-
github_api
|
43
|
-
highline (>= 1.6.15)
|
44
|
-
nokogiri (>= 1.5.10)
|
45
|
-
rake
|
46
|
-
rdoc
|
47
|
-
semver
|
48
|
-
jwt (1.5.6)
|
49
|
-
mime-types (2.99.3)
|
50
|
-
minitest (5.11.3)
|
51
|
-
multi_json (1.13.1)
|
52
|
-
multi_xml (0.6.0)
|
53
|
-
multipart-post (2.0.0)
|
54
|
-
nokogiri (1.5.11)
|
55
|
-
oauth2 (1.4.0)
|
56
|
-
faraday (>= 0.8, < 0.13)
|
57
|
-
jwt (~> 1.0)
|
58
|
-
multi_json (~> 1.3)
|
59
|
-
multi_xml (~> 0.5)
|
60
|
-
rack (>= 1.2, < 3)
|
61
|
-
psych (2.2.4)
|
62
|
-
rack (1.6.9)
|
63
|
-
rake (10.5.0)
|
64
|
-
rdoc (5.1.0)
|
65
|
-
semver (1.0.1)
|
66
|
-
sqlite3 (1.3.13)
|
67
|
-
thor (0.20.0)
|
68
|
-
thread_safe (0.3.6)
|
69
|
-
tzinfo (1.2.5)
|
70
|
-
thread_safe (~> 0.1)
|
71
|
-
|
72
|
-
PLATFORMS
|
73
|
-
ruby
|
74
|
-
|
75
|
-
DEPENDENCIES
|
76
|
-
activerecord (~> 4.2.3)
|
77
|
-
appraisal
|
78
|
-
git (~> 1.2.9)
|
79
|
-
highline (~> 1.6.0)
|
80
|
-
i18n (~> 0.7.0)
|
81
|
-
jeweler (~> 2.1.1)
|
82
|
-
minitest
|
83
|
-
nokogiri (~> 1.5.0)
|
84
|
-
psych (< 3)
|
85
|
-
rack (~> 1.6)
|
86
|
-
rake (~> 10.4)
|
87
|
-
rdoc (>= 2.4.2, < 6)
|
88
|
-
sqlite3
|
89
|
-
|
90
|
-
BUNDLED WITH
|
91
|
-
1.16.1
|
data/gemfiles/5.0.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 5.0.0"
|
6
|
-
gem "highline", "~> 1.6.0", :group => :test
|
7
|
-
gem "rake", "~> 10.4", :group => :test
|
8
|
-
gem "rack", "~> 1.6", :group => :test
|
9
|
-
gem "git", "~> 1.2.9", :group => :test
|
10
|
-
gem "minitest", :group => :test
|
11
|
-
gem "appraisal", :group => :test
|
12
|
-
gem "sqlite3", :group => :test
|
13
|
-
gem "rdoc", ">= 2.4.2", "< 6", :group => :test
|
14
|
-
gem "nokogiri", "~> 1.5.0", :group => :test
|
15
|
-
gem "jeweler", :group => :test
|
16
|
-
gem "i18n", "~> 0.7.0"
|
data/gemfiles/5.0.gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (5.0.7)
|
5
|
-
activesupport (= 5.0.7)
|
6
|
-
activerecord (5.0.7)
|
7
|
-
activemodel (= 5.0.7)
|
8
|
-
activesupport (= 5.0.7)
|
9
|
-
arel (~> 7.0)
|
10
|
-
activesupport (5.0.7)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 0.7, < 2)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
addressable (2.4.0)
|
16
|
-
appraisal (2.2.0)
|
17
|
-
bundler
|
18
|
-
rake
|
19
|
-
thor (>= 0.14.0)
|
20
|
-
arel (7.1.4)
|
21
|
-
builder (3.2.3)
|
22
|
-
concurrent-ruby (1.0.5)
|
23
|
-
descendants_tracker (0.0.4)
|
24
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
25
|
-
faraday (0.9.2)
|
26
|
-
multipart-post (>= 1.2, < 3)
|
27
|
-
git (1.2.9.1)
|
28
|
-
github_api (0.16.0)
|
29
|
-
addressable (~> 2.4.0)
|
30
|
-
descendants_tracker (~> 0.0.4)
|
31
|
-
faraday (~> 0.8, < 0.10)
|
32
|
-
hashie (>= 3.4)
|
33
|
-
mime-types (>= 1.16, < 3.0)
|
34
|
-
oauth2 (~> 1.0)
|
35
|
-
hashie (3.5.7)
|
36
|
-
highline (1.6.21)
|
37
|
-
i18n (0.7.0)
|
38
|
-
jeweler (2.3.9)
|
39
|
-
builder
|
40
|
-
bundler
|
41
|
-
git (>= 1.2.5)
|
42
|
-
github_api (~> 0.16.0)
|
43
|
-
highline (>= 1.6.15)
|
44
|
-
nokogiri (>= 1.5.10)
|
45
|
-
psych
|
46
|
-
rake
|
47
|
-
rdoc
|
48
|
-
semver2
|
49
|
-
jwt (1.5.6)
|
50
|
-
mime-types (2.99.3)
|
51
|
-
minitest (5.11.3)
|
52
|
-
multi_json (1.13.1)
|
53
|
-
multi_xml (0.6.0)
|
54
|
-
multipart-post (2.0.0)
|
55
|
-
nokogiri (1.5.11)
|
56
|
-
oauth2 (1.4.0)
|
57
|
-
faraday (>= 0.8, < 0.13)
|
58
|
-
jwt (~> 1.0)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
multi_xml (~> 0.5)
|
61
|
-
rack (>= 1.2, < 3)
|
62
|
-
psych (3.0.2)
|
63
|
-
rack (1.6.9)
|
64
|
-
rake (10.5.0)
|
65
|
-
rdoc (5.1.0)
|
66
|
-
semver2 (3.4.2)
|
67
|
-
sqlite3 (1.3.13)
|
68
|
-
thor (0.20.0)
|
69
|
-
thread_safe (0.3.6)
|
70
|
-
tzinfo (1.2.5)
|
71
|
-
thread_safe (~> 0.1)
|
72
|
-
|
73
|
-
PLATFORMS
|
74
|
-
ruby
|
75
|
-
|
76
|
-
DEPENDENCIES
|
77
|
-
activerecord (~> 5.0.0)
|
78
|
-
appraisal
|
79
|
-
git (~> 1.2.9)
|
80
|
-
highline (~> 1.6.0)
|
81
|
-
i18n (~> 0.7.0)
|
82
|
-
jeweler
|
83
|
-
minitest
|
84
|
-
nokogiri (~> 1.5.0)
|
85
|
-
rack (~> 1.6)
|
86
|
-
rake (~> 10.4)
|
87
|
-
rdoc (>= 2.4.2, < 6)
|
88
|
-
sqlite3
|
89
|
-
|
90
|
-
BUNDLED WITH
|
91
|
-
1.16.1
|
data/gemfiles/5.1.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 5.1.0"
|
6
|
-
gem "highline", "~> 1.6.0", :group => :test
|
7
|
-
gem "rake", "~> 10.4", :group => :test
|
8
|
-
gem "rack", "~> 1.6", :group => :test
|
9
|
-
gem "git", "~> 1.2.9", :group => :test
|
10
|
-
gem "minitest", :group => :test
|
11
|
-
gem "appraisal", :group => :test
|
12
|
-
gem "sqlite3", :group => :test
|
13
|
-
gem "rdoc", ">= 2.4.2", "< 6", :group => :test
|
14
|
-
gem "nokogiri", "~> 1.5.0", :group => :test
|
15
|
-
gem "jeweler", :group => :test
|
16
|
-
gem "i18n", "~> 0.7.0"
|
data/gemfiles/5.1.gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (5.1.6)
|
5
|
-
activesupport (= 5.1.6)
|
6
|
-
activerecord (5.1.6)
|
7
|
-
activemodel (= 5.1.6)
|
8
|
-
activesupport (= 5.1.6)
|
9
|
-
arel (~> 8.0)
|
10
|
-
activesupport (5.1.6)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 0.7, < 2)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
addressable (2.4.0)
|
16
|
-
appraisal (2.2.0)
|
17
|
-
bundler
|
18
|
-
rake
|
19
|
-
thor (>= 0.14.0)
|
20
|
-
arel (8.0.0)
|
21
|
-
builder (3.2.3)
|
22
|
-
concurrent-ruby (1.0.5)
|
23
|
-
descendants_tracker (0.0.4)
|
24
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
25
|
-
faraday (0.9.2)
|
26
|
-
multipart-post (>= 1.2, < 3)
|
27
|
-
git (1.2.9.1)
|
28
|
-
github_api (0.16.0)
|
29
|
-
addressable (~> 2.4.0)
|
30
|
-
descendants_tracker (~> 0.0.4)
|
31
|
-
faraday (~> 0.8, < 0.10)
|
32
|
-
hashie (>= 3.4)
|
33
|
-
mime-types (>= 1.16, < 3.0)
|
34
|
-
oauth2 (~> 1.0)
|
35
|
-
hashie (3.5.7)
|
36
|
-
highline (1.6.21)
|
37
|
-
i18n (0.7.0)
|
38
|
-
jeweler (2.3.9)
|
39
|
-
builder
|
40
|
-
bundler
|
41
|
-
git (>= 1.2.5)
|
42
|
-
github_api (~> 0.16.0)
|
43
|
-
highline (>= 1.6.15)
|
44
|
-
nokogiri (>= 1.5.10)
|
45
|
-
psych
|
46
|
-
rake
|
47
|
-
rdoc
|
48
|
-
semver2
|
49
|
-
jwt (1.5.6)
|
50
|
-
mime-types (2.99.3)
|
51
|
-
minitest (5.11.3)
|
52
|
-
multi_json (1.13.1)
|
53
|
-
multi_xml (0.6.0)
|
54
|
-
multipart-post (2.0.0)
|
55
|
-
nokogiri (1.5.11)
|
56
|
-
oauth2 (1.4.0)
|
57
|
-
faraday (>= 0.8, < 0.13)
|
58
|
-
jwt (~> 1.0)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
multi_xml (~> 0.5)
|
61
|
-
rack (>= 1.2, < 3)
|
62
|
-
psych (3.0.2)
|
63
|
-
rack (1.6.9)
|
64
|
-
rake (10.5.0)
|
65
|
-
rdoc (5.1.0)
|
66
|
-
semver2 (3.4.2)
|
67
|
-
sqlite3 (1.3.13)
|
68
|
-
thor (0.20.0)
|
69
|
-
thread_safe (0.3.6)
|
70
|
-
tzinfo (1.2.5)
|
71
|
-
thread_safe (~> 0.1)
|
72
|
-
|
73
|
-
PLATFORMS
|
74
|
-
ruby
|
75
|
-
|
76
|
-
DEPENDENCIES
|
77
|
-
activerecord (~> 5.1.0)
|
78
|
-
appraisal
|
79
|
-
git (~> 1.2.9)
|
80
|
-
highline (~> 1.6.0)
|
81
|
-
i18n (~> 0.7.0)
|
82
|
-
jeweler
|
83
|
-
minitest
|
84
|
-
nokogiri (~> 1.5.0)
|
85
|
-
rack (~> 1.6)
|
86
|
-
rake (~> 10.4)
|
87
|
-
rdoc (>= 2.4.2, < 6)
|
88
|
-
sqlite3
|
89
|
-
|
90
|
-
BUNDLED WITH
|
91
|
-
1.16.1
|
data/gemfiles/5.2.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 5.2.0"
|
6
|
-
gem "highline", "~> 1.6.0", :group => :test
|
7
|
-
gem "rake", "~> 10.4", :group => :test
|
8
|
-
gem "rack", "~> 1.6", :group => :test
|
9
|
-
gem "git", "~> 1.2.9", :group => :test
|
10
|
-
gem "minitest", :group => :test
|
11
|
-
gem "appraisal", :group => :test
|
12
|
-
gem "sqlite3", :group => :test
|
13
|
-
gem "rdoc", ">= 2.4.2", "< 6", :group => :test
|
14
|
-
gem "nokogiri", "~> 1.5.0", :group => :test
|
15
|
-
gem "jeweler", :group => :test
|
data/gemfiles/5.2.gemfile.lock
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (5.2.0)
|
5
|
-
activesupport (= 5.2.0)
|
6
|
-
activerecord (5.2.0)
|
7
|
-
activemodel (= 5.2.0)
|
8
|
-
activesupport (= 5.2.0)
|
9
|
-
arel (>= 9.0)
|
10
|
-
activesupport (5.2.0)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 0.7, < 2)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
addressable (2.4.0)
|
16
|
-
appraisal (2.2.0)
|
17
|
-
bundler
|
18
|
-
rake
|
19
|
-
thor (>= 0.14.0)
|
20
|
-
arel (9.0.0)
|
21
|
-
builder (3.2.3)
|
22
|
-
concurrent-ruby (1.0.5)
|
23
|
-
descendants_tracker (0.0.4)
|
24
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
25
|
-
faraday (0.9.2)
|
26
|
-
multipart-post (>= 1.2, < 3)
|
27
|
-
git (1.2.9.1)
|
28
|
-
github_api (0.16.0)
|
29
|
-
addressable (~> 2.4.0)
|
30
|
-
descendants_tracker (~> 0.0.4)
|
31
|
-
faraday (~> 0.8, < 0.10)
|
32
|
-
hashie (>= 3.4)
|
33
|
-
mime-types (>= 1.16, < 3.0)
|
34
|
-
oauth2 (~> 1.0)
|
35
|
-
hashie (3.5.7)
|
36
|
-
highline (1.6.21)
|
37
|
-
i18n (1.0.0)
|
38
|
-
concurrent-ruby (~> 1.0)
|
39
|
-
jeweler (2.3.9)
|
40
|
-
builder
|
41
|
-
bundler
|
42
|
-
git (>= 1.2.5)
|
43
|
-
github_api (~> 0.16.0)
|
44
|
-
highline (>= 1.6.15)
|
45
|
-
nokogiri (>= 1.5.10)
|
46
|
-
psych
|
47
|
-
rake
|
48
|
-
rdoc
|
49
|
-
semver2
|
50
|
-
jwt (1.5.6)
|
51
|
-
mime-types (2.99.3)
|
52
|
-
minitest (5.11.3)
|
53
|
-
multi_json (1.13.1)
|
54
|
-
multi_xml (0.6.0)
|
55
|
-
multipart-post (2.0.0)
|
56
|
-
nokogiri (1.5.11)
|
57
|
-
oauth2 (1.4.0)
|
58
|
-
faraday (>= 0.8, < 0.13)
|
59
|
-
jwt (~> 1.0)
|
60
|
-
multi_json (~> 1.3)
|
61
|
-
multi_xml (~> 0.5)
|
62
|
-
rack (>= 1.2, < 3)
|
63
|
-
psych (3.0.2)
|
64
|
-
rack (1.6.9)
|
65
|
-
rake (10.5.0)
|
66
|
-
rdoc (5.1.0)
|
67
|
-
semver2 (3.4.2)
|
68
|
-
sqlite3 (1.3.13)
|
69
|
-
thor (0.20.0)
|
70
|
-
thread_safe (0.3.6)
|
71
|
-
tzinfo (1.2.5)
|
72
|
-
thread_safe (~> 0.1)
|
73
|
-
|
74
|
-
PLATFORMS
|
75
|
-
ruby
|
76
|
-
|
77
|
-
DEPENDENCIES
|
78
|
-
activerecord (~> 5.2.0)
|
79
|
-
appraisal
|
80
|
-
git (~> 1.2.9)
|
81
|
-
highline (~> 1.6.0)
|
82
|
-
jeweler
|
83
|
-
minitest
|
84
|
-
nokogiri (~> 1.5.0)
|
85
|
-
rack (~> 1.6)
|
86
|
-
rake (~> 10.4)
|
87
|
-
rdoc (>= 2.4.2, < 6)
|
88
|
-
sqlite3
|
89
|
-
|
90
|
-
BUNDLED WITH
|
91
|
-
1.16.1
|
data/test/database.yml
DELETED
data/test/models.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
module Animal
|
2
|
-
class Human < ActiveRecord::Base
|
3
|
-
has_many :pigs
|
4
|
-
|
5
|
-
has_many :ownerships
|
6
|
-
has_many :chickens, :through => :ownerships
|
7
|
-
end
|
8
|
-
|
9
|
-
class Pig < ActiveRecord::Base
|
10
|
-
belongs_to :human
|
11
|
-
end
|
12
|
-
|
13
|
-
class Bird < ActiveRecord::Base
|
14
|
-
belongs_to :planet
|
15
|
-
end
|
16
|
-
|
17
|
-
class Chicken < Bird
|
18
|
-
has_many :ownerships
|
19
|
-
has_many :humans, :through => :ownerships
|
20
|
-
end
|
21
|
-
|
22
|
-
class Dove < Bird
|
23
|
-
end
|
24
|
-
|
25
|
-
class Planet < ActiveRecord::Base
|
26
|
-
has_many :birds
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
class Ownership < ActiveRecord::Base
|
31
|
-
belongs_to :human
|
32
|
-
belongs_to :chicken
|
33
|
-
|
34
|
-
validates_uniqueness_of :chicken_id, :scope => :human_id
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
class GoldPiece < ActiveRecord::Base; belongs_to :treasure end
|
40
|
-
class Matey < ActiveRecord::Base; belongs_to :pirate end
|
41
|
-
class BattleShip < ActiveRecord::Base; has_many :pirates, :as => :ship end
|
42
|
-
|
43
|
-
class Parrot < ActiveRecord::Base
|
44
|
-
belongs_to :pirate
|
45
|
-
has_many :parrot_cages, :foreign_key => :owner_id, :inverse_of => :parrot, :class_name => 'Cage'
|
46
|
-
attr_accessor :cloned_from_id
|
47
|
-
end
|
48
|
-
|
49
|
-
class Cage < ActiveRecord::Base
|
50
|
-
belongs_to :parrot, :foreign_key => :owner_id, :inverse_of => :parrot_cages
|
51
|
-
belongs_to :pirate, :foreign_key => :owner_id, :inverse_of => :pirate_cages
|
52
|
-
end
|
53
|
-
|
54
|
-
class Pirate < ActiveRecord::Base
|
55
|
-
belongs_to :ship, :polymorphic => true
|
56
|
-
|
57
|
-
has_many :mateys
|
58
|
-
has_many :treasures, :foreign_key => 'owner'
|
59
|
-
has_many :gold_pieces, :through => :treasures
|
60
|
-
has_one :parrot
|
61
|
-
has_many :pirate_cages, :inverse_of => :pirate, :foreign_key => :owner_id, :class_name => 'Cage'
|
62
|
-
|
63
|
-
serialize :piastres
|
64
|
-
|
65
|
-
attr_accessor :cloned_from_id
|
66
|
-
end
|
67
|
-
|
68
|
-
class Treasure < ActiveRecord::Base
|
69
|
-
belongs_to :pirate, :foreign_key => :owner
|
70
|
-
belongs_to :matey
|
71
|
-
has_many :gold_pieces
|
72
|
-
end
|
73
|
-
|
74
|
-
class Person < ActiveRecord::Base
|
75
|
-
has_and_belongs_to_many :cars
|
76
|
-
end
|
77
|
-
|
78
|
-
class Car < ActiveRecord::Base
|
79
|
-
has_and_belongs_to_many :people
|
80
|
-
end
|
81
|
-
|
82
|
-
class Coin < ActiveRecord::Base
|
83
|
-
has_and_belongs_to_many :people
|
84
|
-
end
|
85
|
-
|
86
|
-
class ChildWithValidation < ActiveRecord::Base
|
87
|
-
belongs_to :parent, :class_name => 'ParentWithValidation'
|
88
|
-
validates :name, :presence => true
|
89
|
-
end
|
90
|
-
|
91
|
-
class ParentWithValidation < ActiveRecord::Base
|
92
|
-
has_many :children, :class_name => 'ChildWithValidation'
|
93
|
-
validates :name, :presence => true
|
94
|
-
end
|
95
|
-
|
96
|
-
class Part < ActiveRecord::Base
|
97
|
-
# belongs_to :parent_part, :class_name => 'Part'
|
98
|
-
has_many :child_parts, :class_name => 'Part', :foreign_key => 'parent_part_id'
|
99
|
-
end
|
100
|
-
|
101
|
-
class Student < ActiveRecord::Base
|
102
|
-
has_many :student_assignments, :dependent => :destroy
|
103
|
-
has_many :subjects, :through => :student_assignments
|
104
|
-
end
|
105
|
-
|
106
|
-
class Subject < ActiveRecord::Base
|
107
|
-
has_many :student_assignments, :dependent => :destroy
|
108
|
-
has_many :students, :through => :student_assignments
|
109
|
-
end
|
110
|
-
|
111
|
-
class StudentAssignment < ActiveRecord::Base
|
112
|
-
belongs_to :subject
|
113
|
-
belongs_to :student
|
114
|
-
end
|
115
|
-
|
116
|
-
class Building < ActiveRecord::Base
|
117
|
-
has_many :apartments
|
118
|
-
has_many :contractors
|
119
|
-
end
|
120
|
-
|
121
|
-
class Apartment < ActiveRecord::Base
|
122
|
-
belongs_to :building
|
123
|
-
has_and_belongs_to_many :contractors
|
124
|
-
end
|
125
|
-
|
126
|
-
class Contractor < ActiveRecord::Base
|
127
|
-
belongs_to :building
|
128
|
-
has_and_belongs_to_many :apartments
|
129
|
-
end
|
130
|
-
|
131
|
-
class User < ActiveRecord::Base
|
132
|
-
has_many :orders
|
133
|
-
end
|
134
|
-
|
135
|
-
class Order < ActiveRecord::Base
|
136
|
-
belongs_to :user
|
137
|
-
has_many :products
|
138
|
-
end
|
139
|
-
|
140
|
-
class Product < ActiveRecord::Base
|
141
|
-
belongs_to :order
|
142
|
-
end
|
data/test/schema.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define(:version => 1) do
|
2
|
-
create_table :pirates, :force => true do |t|
|
3
|
-
t.column :name, :string
|
4
|
-
t.column :nick_name, :string, :default => 'no nickname'
|
5
|
-
t.column :age, :string
|
6
|
-
t.column :ship_id, :integer
|
7
|
-
t.column :ship_type, :string
|
8
|
-
t.column :piastres, :text, :default => [].to_yaml
|
9
|
-
end
|
10
|
-
|
11
|
-
create_table :parrots, :force => true do |t|
|
12
|
-
t.column :name, :string
|
13
|
-
t.column :age, :integer
|
14
|
-
t.column :pirate_id, :integer
|
15
|
-
end
|
16
|
-
|
17
|
-
create_table :mateys, :force => true do |t|
|
18
|
-
t.column :name, :string
|
19
|
-
t.column :pirate_id, :integer
|
20
|
-
end
|
21
|
-
|
22
|
-
create_table :treasures, :force => true do |t|
|
23
|
-
t.column :found_at, :string
|
24
|
-
t.column :owner, :integer
|
25
|
-
t.column :matey_id, :integer
|
26
|
-
end
|
27
|
-
|
28
|
-
create_table :cages, :force => true do |t|
|
29
|
-
t.column :name, :string
|
30
|
-
t.column :owner_id, :integer
|
31
|
-
end
|
32
|
-
|
33
|
-
create_table :gold_pieces, :force => true do |t|
|
34
|
-
t.column :treasure_id, :integer
|
35
|
-
end
|
36
|
-
|
37
|
-
create_table :battle_ships, :force => true do |t|
|
38
|
-
t.column :name, :string
|
39
|
-
end
|
40
|
-
|
41
|
-
create_table :pigs, :force => true do |t|
|
42
|
-
t.column :name, :string
|
43
|
-
t.column :human_id, :integer
|
44
|
-
end
|
45
|
-
|
46
|
-
create_table :humen, :force => true do |t|
|
47
|
-
t.column :name, :string
|
48
|
-
end
|
49
|
-
|
50
|
-
create_table :planets, :force => true do |t|
|
51
|
-
t.column :name, :string
|
52
|
-
end
|
53
|
-
|
54
|
-
create_table :birds, :force => true do |t|
|
55
|
-
t.column :name, :string
|
56
|
-
t.column :type, :string
|
57
|
-
t.column :planet_id, :integer
|
58
|
-
end
|
59
|
-
|
60
|
-
create_table :ownerships, :force => true do |t|
|
61
|
-
t.column :human_id, :integer
|
62
|
-
t.column :chicken_id, :integer
|
63
|
-
end
|
64
|
-
|
65
|
-
create_table :cars, :force => true do |t|
|
66
|
-
t.column :name, :string
|
67
|
-
end
|
68
|
-
|
69
|
-
create_table :coins, :force => true do |t|
|
70
|
-
t.column :value, :integer
|
71
|
-
end
|
72
|
-
|
73
|
-
create_table :people, :force => true do |t|
|
74
|
-
t.column :name, :string
|
75
|
-
end
|
76
|
-
|
77
|
-
create_table :cars_people, :id => false, :force => true do |t|
|
78
|
-
t.column :car_id, :integer
|
79
|
-
t.column :person_id, :integer
|
80
|
-
end
|
81
|
-
|
82
|
-
create_table :coins_people, :id => false, :force => true do |t|
|
83
|
-
t.column :coin_id, :integer
|
84
|
-
t.column :person_id, :integer
|
85
|
-
end
|
86
|
-
|
87
|
-
create_table :parent_with_validations, :force => true do |t|
|
88
|
-
t.column :name, :string
|
89
|
-
end
|
90
|
-
|
91
|
-
create_table :child_with_validations, :force => true do |t|
|
92
|
-
t.column :name, :string
|
93
|
-
t.column :parent_with_validation_id, :integer
|
94
|
-
end
|
95
|
-
|
96
|
-
create_table :parts, :force => true do |t|
|
97
|
-
t.column :name, :string
|
98
|
-
t.column :parent_part_id, :integer
|
99
|
-
end
|
100
|
-
|
101
|
-
create_table :students, :force => true do |t|
|
102
|
-
t.column :name, :string
|
103
|
-
end
|
104
|
-
|
105
|
-
create_table :subjects, :force => true do |t|
|
106
|
-
t.column :name, :string
|
107
|
-
end
|
108
|
-
|
109
|
-
create_table :student_assignments, :force => true do |t|
|
110
|
-
t.column :student_id, :integer
|
111
|
-
t.column :subject_id, :integer
|
112
|
-
end
|
113
|
-
|
114
|
-
create_table :buildings, :force => true do |t|
|
115
|
-
t.column :name, :string
|
116
|
-
end
|
117
|
-
|
118
|
-
create_table :apartments, :force => true do |t|
|
119
|
-
t.column :number, :string
|
120
|
-
t.column :building_id, :integer
|
121
|
-
end
|
122
|
-
|
123
|
-
create_table :contractors, :force => true do |t|
|
124
|
-
t.column :name, :string
|
125
|
-
t.column :building_id, :integer
|
126
|
-
end
|
127
|
-
|
128
|
-
create_table :apartments_contractors, :force => true do |t|
|
129
|
-
t.column :apartment_id, :integer
|
130
|
-
t.column :contractor_id, :integer
|
131
|
-
end
|
132
|
-
|
133
|
-
create_table :users, :force => true do |t|
|
134
|
-
t.column :name, :string
|
135
|
-
t.column :contractor_id, :integer
|
136
|
-
end
|
137
|
-
|
138
|
-
create_table :orders, :force => true do |t|
|
139
|
-
t.column :user_id, :integer
|
140
|
-
end
|
141
|
-
|
142
|
-
create_table :products, :force => true do |t|
|
143
|
-
t.column :name, :string
|
144
|
-
t.column :order_id, :integer
|
145
|
-
end
|
146
|
-
end
|