deep_cloneable 2.1.1 → 2.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 +3 -1
- data/Gemfile.lock +42 -38
- data/LICENSE +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/deep_cloneable.gemspec +7 -7
- data/gemfiles/3.1.gemfile +1 -0
- data/gemfiles/3.1.gemfile.lock +15 -11
- data/gemfiles/3.2.gemfile +1 -0
- data/gemfiles/3.2.gemfile.lock +21 -17
- data/gemfiles/4.0.gemfile.lock +32 -27
- data/gemfiles/4.1.gemfile.lock +31 -26
- data/gemfiles/4.2.gemfile +1 -1
- data/gemfiles/4.2.gemfile.lock +33 -28
- data/lib/deep_cloneable.rb +2 -0
- data/readme.md +127 -0
- data/test/test_deep_cloneable.rb +15 -3
- metadata +6 -6
- data/README.rdoc +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e942e18b8b8a7bbcd53d9bcc0323316216a4605f
|
4
|
+
data.tar.gz: b3e1250b6d10ff291bcf5b6ca93670a98d2e762c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84638e643bd06868cecde89005007160d11f10c35f390f0f7357bfce432409dea6d3a4eba6929786ee2bf6fac0eff7cac257fe7dd9a348c71b50483d4e043213
|
7
|
+
data.tar.gz: 414302546e5ffe0c85ad47daf5d1d6d275c13736ef6668d406b2ff66be9104d16ee2c2960cebc3a5275dedbd36669b6c400c77f37bdb71f0471d21e44fc0d7e2
|
data/Appraisals
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
appraise '3.1' do
|
2
2
|
gem 'activerecord', '~> 3.1.0'
|
3
|
+
gem "addressable", "~> 2.3.8"
|
3
4
|
end
|
4
5
|
|
5
6
|
appraise '3.2' do
|
6
7
|
gem 'activerecord', '~> 3.2.0'
|
8
|
+
gem "addressable", "~> 2.3.8"
|
7
9
|
end
|
8
10
|
|
9
11
|
appraise '4.0' do
|
@@ -15,6 +17,6 @@ appraise '4.1' do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
appraise '4.2' do
|
18
|
-
gem 'activerecord', '~> 4.2.
|
20
|
+
gem 'activerecord', '~> 4.2.3'
|
19
21
|
gem 'i18n', '~> 0.7.0'
|
20
22
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (4.
|
5
|
-
activesupport (= 4.
|
6
|
-
builder (~> 3.1
|
7
|
-
activerecord (4.
|
8
|
-
activemodel (= 4.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
minitest (~> 4.2)
|
16
|
-
multi_json (~> 1.3)
|
4
|
+
activemodel (4.1.14)
|
5
|
+
activesupport (= 4.1.14)
|
6
|
+
builder (~> 3.1)
|
7
|
+
activerecord (4.1.14)
|
8
|
+
activemodel (= 4.1.14)
|
9
|
+
activesupport (= 4.1.14)
|
10
|
+
arel (~> 5.0.0)
|
11
|
+
activesupport (4.1.14)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
17
15
|
thread_safe (~> 0.1)
|
18
|
-
tzinfo (~>
|
19
|
-
addressable (2.
|
20
|
-
appraisal (1.0
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
addressable (2.4.0)
|
18
|
+
appraisal (2.1.0)
|
21
19
|
bundler
|
22
20
|
rake
|
23
21
|
thor (>= 0.14.0)
|
24
|
-
arel (
|
25
|
-
builder (3.
|
26
|
-
|
27
|
-
|
22
|
+
arel (5.0.1.20140414130214)
|
23
|
+
builder (3.2.2)
|
24
|
+
descendants_tracker (0.0.4)
|
25
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
26
|
+
faraday (0.9.2)
|
27
|
+
multipart-post (>= 1.2, < 3)
|
28
28
|
git (1.2.9.1)
|
29
|
-
github_api (0.
|
30
|
-
addressable
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
github_api (0.13.1)
|
30
|
+
addressable (~> 2.4.0)
|
31
|
+
descendants_tracker (~> 0.0.4)
|
32
|
+
faraday (~> 0.8, < 0.10)
|
33
|
+
hashie (>= 3.4)
|
34
|
+
multi_json (>= 1.7.5, < 2.0)
|
35
35
|
oauth2
|
36
|
-
hashie (3.4.
|
36
|
+
hashie (3.4.3)
|
37
37
|
highline (1.6.21)
|
38
|
-
i18n (0.6.
|
38
|
+
i18n (0.6.11)
|
39
39
|
jeweler (2.0.1)
|
40
40
|
builder
|
41
41
|
bundler (>= 1.0)
|
@@ -45,12 +45,12 @@ GEM
|
|
45
45
|
nokogiri (>= 1.5.10)
|
46
46
|
rake
|
47
47
|
rdoc
|
48
|
-
json (1.8.
|
49
|
-
jwt (1.2
|
50
|
-
minitest (
|
51
|
-
multi_json (1.
|
48
|
+
json (1.8.3)
|
49
|
+
jwt (1.5.2)
|
50
|
+
minitest (5.8.3)
|
51
|
+
multi_json (1.11.2)
|
52
52
|
multi_xml (0.5.5)
|
53
|
-
multipart-post (
|
53
|
+
multipart-post (2.0.0)
|
54
54
|
nokogiri (1.5.11)
|
55
55
|
oauth2 (1.0.0)
|
56
56
|
faraday (>= 0.8, < 0.10)
|
@@ -58,14 +58,15 @@ GEM
|
|
58
58
|
multi_json (~> 1.3)
|
59
59
|
multi_xml (~> 0.5)
|
60
60
|
rack (~> 1.2)
|
61
|
-
rack (1.6.
|
61
|
+
rack (1.6.4)
|
62
62
|
rake (10.4.2)
|
63
|
-
rdoc (4.2.
|
63
|
+
rdoc (4.2.1)
|
64
64
|
json (~> 1.4)
|
65
|
-
sqlite3 (1.3.
|
65
|
+
sqlite3 (1.3.11)
|
66
66
|
thor (0.19.1)
|
67
|
-
thread_safe (0.3.
|
68
|
-
tzinfo (
|
67
|
+
thread_safe (0.3.5)
|
68
|
+
tzinfo (1.2.2)
|
69
|
+
thread_safe (~> 0.1)
|
69
70
|
|
70
71
|
PLATFORMS
|
71
72
|
ruby
|
@@ -80,3 +81,6 @@ DEPENDENCIES
|
|
80
81
|
nokogiri (~> 1.5.0)
|
81
82
|
rdoc (>= 2.4.2)
|
82
83
|
sqlite3
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.10.6
|
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
Jeweler::Tasks.new do |gem|
|
8
8
|
gem.name = "deep_cloneable"
|
9
9
|
gem.summary = %Q{This gem gives every ActiveRecord::Base object the possibility to do a deep clone.}
|
10
|
-
gem.description = %Q{Extends the functionality of ActiveRecord::Base#
|
10
|
+
gem.description = %Q{Extends the functionality of ActiveRecord::Base#dup to perform a deep clone that includes user specified associations. }
|
11
11
|
gem.email = "r.j.delange@nedforce.nl"
|
12
12
|
gem.homepage = "http://github.com/moiristo/deep_cloneable"
|
13
13
|
gem.authors = ["Reinier de Lange"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/deep_cloneable.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: deep_cloneable 2.
|
5
|
+
# stub: deep_cloneable 2.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "deep_cloneable"
|
9
|
-
s.version = "2.
|
9
|
+
s.version = "2.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Reinier de Lange"]
|
14
|
-
s.date = "
|
15
|
-
s.description = "Extends the functionality of ActiveRecord::Base#
|
14
|
+
s.date = "2016-01-11"
|
15
|
+
s.description = "Extends the functionality of ActiveRecord::Base#dup to perform a deep clone that includes user specified associations. "
|
16
16
|
s.email = "r.j.delange@nedforce.nl"
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
"
|
19
|
+
"readme.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Gemfile",
|
26
26
|
"Gemfile.lock",
|
27
27
|
"LICENSE",
|
28
|
-
"README.rdoc",
|
29
28
|
"Rakefile",
|
30
29
|
"VERSION",
|
31
30
|
"deep_cloneable.gemspec",
|
@@ -41,6 +40,7 @@ Gem::Specification.new do |s|
|
|
41
40
|
"gemfiles/4.2.gemfile.lock",
|
42
41
|
"init.rb",
|
43
42
|
"lib/deep_cloneable.rb",
|
43
|
+
"readme.md",
|
44
44
|
"test/database.yml",
|
45
45
|
"test/models.rb",
|
46
46
|
"test/schema.rb",
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
]
|
50
50
|
s.homepage = "http://github.com/moiristo/deep_cloneable"
|
51
51
|
s.licenses = ["MIT"]
|
52
|
-
s.rubygems_version = "2.4.
|
52
|
+
s.rubygems_version = "2.4.8"
|
53
53
|
s.summary = "This gem gives every ActiveRecord::Base object the possibility to do a deep clone."
|
54
54
|
|
55
55
|
if s.respond_to? :specification_version then
|
data/gemfiles/3.1.gemfile
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
@@ -12,8 +12,8 @@ GEM
|
|
12
12
|
tzinfo (~> 0.3.29)
|
13
13
|
activesupport (3.1.12)
|
14
14
|
multi_json (~> 1.0)
|
15
|
-
addressable (2.3.
|
16
|
-
appraisal (1.0
|
15
|
+
addressable (2.3.8)
|
16
|
+
appraisal (2.1.0)
|
17
17
|
bundler
|
18
18
|
rake
|
19
19
|
thor (>= 0.14.0)
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
multi_json (~> 1.4)
|
30
30
|
nokogiri (~> 1.5.2)
|
31
31
|
oauth2
|
32
|
-
hashie (3.4.
|
32
|
+
hashie (3.4.3)
|
33
33
|
highline (1.6.21)
|
34
34
|
i18n (0.6.11)
|
35
35
|
jeweler (2.0.1)
|
@@ -41,10 +41,10 @@ GEM
|
|
41
41
|
nokogiri (>= 1.5.10)
|
42
42
|
rake
|
43
43
|
rdoc
|
44
|
-
json (1.8.
|
45
|
-
jwt (1.2
|
46
|
-
minitest (5.
|
47
|
-
multi_json (1.11.
|
44
|
+
json (1.8.3)
|
45
|
+
jwt (1.5.2)
|
46
|
+
minitest (5.8.3)
|
47
|
+
multi_json (1.11.2)
|
48
48
|
multi_xml (0.5.5)
|
49
49
|
multipart-post (1.2.0)
|
50
50
|
nokogiri (1.5.11)
|
@@ -54,19 +54,20 @@ GEM
|
|
54
54
|
multi_json (~> 1.3)
|
55
55
|
multi_xml (~> 0.5)
|
56
56
|
rack (~> 1.2)
|
57
|
-
rack (1.6.
|
57
|
+
rack (1.6.4)
|
58
58
|
rake (10.4.2)
|
59
|
-
rdoc (4.2.
|
59
|
+
rdoc (4.2.1)
|
60
60
|
json (~> 1.4)
|
61
|
-
sqlite3 (1.3.
|
61
|
+
sqlite3 (1.3.11)
|
62
62
|
thor (0.19.1)
|
63
|
-
tzinfo (0.3.
|
63
|
+
tzinfo (0.3.46)
|
64
64
|
|
65
65
|
PLATFORMS
|
66
66
|
ruby
|
67
67
|
|
68
68
|
DEPENDENCIES
|
69
69
|
activerecord (~> 3.1.0)
|
70
|
+
addressable (~> 2.3.8)
|
70
71
|
appraisal
|
71
72
|
highline (~> 1.6.0)
|
72
73
|
i18n (~> 0.6.5)
|
@@ -75,3 +76,6 @@ DEPENDENCIES
|
|
75
76
|
nokogiri (~> 1.5.0)
|
76
77
|
rdoc (>= 2.4.2)
|
77
78
|
sqlite3
|
79
|
+
|
80
|
+
BUNDLED WITH
|
81
|
+
1.10.6
|
data/gemfiles/3.2.gemfile
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (3.2.
|
5
|
-
activesupport (= 3.2.
|
4
|
+
activemodel (3.2.22)
|
5
|
+
activesupport (= 3.2.22)
|
6
6
|
builder (~> 3.0.0)
|
7
|
-
activerecord (3.2.
|
8
|
-
activemodel (= 3.2.
|
9
|
-
activesupport (= 3.2.
|
7
|
+
activerecord (3.2.22)
|
8
|
+
activemodel (= 3.2.22)
|
9
|
+
activesupport (= 3.2.22)
|
10
10
|
arel (~> 3.0.2)
|
11
11
|
tzinfo (~> 0.3.29)
|
12
|
-
activesupport (3.2.
|
12
|
+
activesupport (3.2.22)
|
13
13
|
i18n (~> 0.6, >= 0.6.4)
|
14
14
|
multi_json (~> 1.0)
|
15
|
-
addressable (2.3.
|
16
|
-
appraisal (1.0
|
15
|
+
addressable (2.3.8)
|
16
|
+
appraisal (2.1.0)
|
17
17
|
bundler
|
18
18
|
rake
|
19
19
|
thor (>= 0.14.0)
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
multi_json (~> 1.4)
|
30
30
|
nokogiri (~> 1.5.2)
|
31
31
|
oauth2
|
32
|
-
hashie (3.4.
|
32
|
+
hashie (3.4.3)
|
33
33
|
highline (1.6.21)
|
34
34
|
i18n (0.6.11)
|
35
35
|
jeweler (2.0.1)
|
@@ -41,10 +41,10 @@ GEM
|
|
41
41
|
nokogiri (>= 1.5.10)
|
42
42
|
rake
|
43
43
|
rdoc
|
44
|
-
json (1.8.
|
45
|
-
jwt (1.2
|
46
|
-
minitest (5.
|
47
|
-
multi_json (1.11.
|
44
|
+
json (1.8.3)
|
45
|
+
jwt (1.5.2)
|
46
|
+
minitest (5.8.3)
|
47
|
+
multi_json (1.11.2)
|
48
48
|
multi_xml (0.5.5)
|
49
49
|
multipart-post (1.2.0)
|
50
50
|
nokogiri (1.5.11)
|
@@ -54,19 +54,20 @@ GEM
|
|
54
54
|
multi_json (~> 1.3)
|
55
55
|
multi_xml (~> 0.5)
|
56
56
|
rack (~> 1.2)
|
57
|
-
rack (1.6.
|
57
|
+
rack (1.6.4)
|
58
58
|
rake (10.4.2)
|
59
|
-
rdoc (4.2.
|
59
|
+
rdoc (4.2.1)
|
60
60
|
json (~> 1.4)
|
61
|
-
sqlite3 (1.3.
|
61
|
+
sqlite3 (1.3.11)
|
62
62
|
thor (0.19.1)
|
63
|
-
tzinfo (0.3.
|
63
|
+
tzinfo (0.3.46)
|
64
64
|
|
65
65
|
PLATFORMS
|
66
66
|
ruby
|
67
67
|
|
68
68
|
DEPENDENCIES
|
69
69
|
activerecord (~> 3.2.0)
|
70
|
+
addressable (~> 2.3.8)
|
70
71
|
appraisal
|
71
72
|
highline (~> 1.6.0)
|
72
73
|
i18n (~> 0.6.5)
|
@@ -75,3 +76,6 @@ DEPENDENCIES
|
|
75
76
|
nokogiri (~> 1.5.0)
|
76
77
|
rdoc (>= 2.4.2)
|
77
78
|
sqlite3
|
79
|
+
|
80
|
+
BUNDLED WITH
|
81
|
+
1.10.6
|
data/gemfiles/4.0.gemfile.lock
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (4.0.
|
5
|
-
activesupport (= 4.0.
|
4
|
+
activemodel (4.0.13)
|
5
|
+
activesupport (= 4.0.13)
|
6
6
|
builder (~> 3.1.0)
|
7
|
-
activerecord (4.0.
|
8
|
-
activemodel (= 4.0.
|
7
|
+
activerecord (4.0.13)
|
8
|
+
activemodel (= 4.0.13)
|
9
9
|
activerecord-deprecated_finders (~> 1.0.2)
|
10
|
-
activesupport (= 4.0.
|
10
|
+
activesupport (= 4.0.13)
|
11
11
|
arel (~> 4.0.0)
|
12
|
-
activerecord-deprecated_finders (1.0.
|
13
|
-
activesupport (4.0.
|
12
|
+
activerecord-deprecated_finders (1.0.4)
|
13
|
+
activesupport (4.0.13)
|
14
14
|
i18n (~> 0.6, >= 0.6.9)
|
15
15
|
minitest (~> 4.2)
|
16
16
|
multi_json (~> 1.3)
|
17
17
|
thread_safe (~> 0.1)
|
18
18
|
tzinfo (~> 0.3.37)
|
19
|
-
addressable (2.
|
20
|
-
appraisal (1.0
|
19
|
+
addressable (2.4.0)
|
20
|
+
appraisal (2.1.0)
|
21
21
|
bundler
|
22
22
|
rake
|
23
23
|
thor (>= 0.14.0)
|
24
24
|
arel (4.0.2)
|
25
25
|
builder (3.1.4)
|
26
|
-
|
27
|
-
|
26
|
+
descendants_tracker (0.0.4)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
faraday (0.9.2)
|
29
|
+
multipart-post (>= 1.2, < 3)
|
28
30
|
git (1.2.9.1)
|
29
|
-
github_api (0.
|
30
|
-
addressable
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
github_api (0.13.1)
|
32
|
+
addressable (~> 2.4.0)
|
33
|
+
descendants_tracker (~> 0.0.4)
|
34
|
+
faraday (~> 0.8, < 0.10)
|
35
|
+
hashie (>= 3.4)
|
36
|
+
multi_json (>= 1.7.5, < 2.0)
|
35
37
|
oauth2
|
36
|
-
hashie (3.4.
|
38
|
+
hashie (3.4.3)
|
37
39
|
highline (1.6.21)
|
38
40
|
i18n (0.6.11)
|
39
41
|
jeweler (2.0.1)
|
@@ -45,12 +47,12 @@ GEM
|
|
45
47
|
nokogiri (>= 1.5.10)
|
46
48
|
rake
|
47
49
|
rdoc
|
48
|
-
json (1.8.
|
49
|
-
jwt (1.2
|
50
|
+
json (1.8.3)
|
51
|
+
jwt (1.5.2)
|
50
52
|
minitest (4.7.5)
|
51
|
-
multi_json (1.11.
|
53
|
+
multi_json (1.11.2)
|
52
54
|
multi_xml (0.5.5)
|
53
|
-
multipart-post (
|
55
|
+
multipart-post (2.0.0)
|
54
56
|
nokogiri (1.5.11)
|
55
57
|
oauth2 (1.0.0)
|
56
58
|
faraday (>= 0.8, < 0.10)
|
@@ -58,14 +60,14 @@ GEM
|
|
58
60
|
multi_json (~> 1.3)
|
59
61
|
multi_xml (~> 0.5)
|
60
62
|
rack (~> 1.2)
|
61
|
-
rack (1.6.
|
63
|
+
rack (1.6.4)
|
62
64
|
rake (10.4.2)
|
63
|
-
rdoc (4.2.
|
65
|
+
rdoc (4.2.1)
|
64
66
|
json (~> 1.4)
|
65
|
-
sqlite3 (1.3.
|
67
|
+
sqlite3 (1.3.11)
|
66
68
|
thor (0.19.1)
|
67
|
-
thread_safe (0.3.
|
68
|
-
tzinfo (0.3.
|
69
|
+
thread_safe (0.3.5)
|
70
|
+
tzinfo (0.3.46)
|
69
71
|
|
70
72
|
PLATFORMS
|
71
73
|
ruby
|
@@ -80,3 +82,6 @@ DEPENDENCIES
|
|
80
82
|
nokogiri (~> 1.5.0)
|
81
83
|
rdoc (>= 2.4.2)
|
82
84
|
sqlite3
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
1.10.6
|
data/gemfiles/4.1.gemfile.lock
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (4.1.
|
5
|
-
activesupport (= 4.1.
|
4
|
+
activemodel (4.1.14)
|
5
|
+
activesupport (= 4.1.14)
|
6
6
|
builder (~> 3.1)
|
7
|
-
activerecord (4.1.
|
8
|
-
activemodel (= 4.1.
|
9
|
-
activesupport (= 4.1.
|
7
|
+
activerecord (4.1.14)
|
8
|
+
activemodel (= 4.1.14)
|
9
|
+
activesupport (= 4.1.14)
|
10
10
|
arel (~> 5.0.0)
|
11
|
-
activesupport (4.1.
|
11
|
+
activesupport (4.1.14)
|
12
12
|
i18n (~> 0.6, >= 0.6.9)
|
13
13
|
json (~> 1.7, >= 1.7.7)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
thread_safe (~> 0.1)
|
16
16
|
tzinfo (~> 1.1)
|
17
|
-
addressable (2.
|
18
|
-
appraisal (1.0
|
17
|
+
addressable (2.4.0)
|
18
|
+
appraisal (2.1.0)
|
19
19
|
bundler
|
20
20
|
rake
|
21
21
|
thor (>= 0.14.0)
|
22
22
|
arel (5.0.1.20140414130214)
|
23
23
|
builder (3.2.2)
|
24
|
-
|
25
|
-
|
24
|
+
descendants_tracker (0.0.4)
|
25
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
26
|
+
faraday (0.9.2)
|
27
|
+
multipart-post (>= 1.2, < 3)
|
26
28
|
git (1.2.9.1)
|
27
|
-
github_api (0.
|
28
|
-
addressable
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
github_api (0.13.1)
|
30
|
+
addressable (~> 2.4.0)
|
31
|
+
descendants_tracker (~> 0.0.4)
|
32
|
+
faraday (~> 0.8, < 0.10)
|
33
|
+
hashie (>= 3.4)
|
34
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
35
|
oauth2
|
34
|
-
hashie (3.4.
|
36
|
+
hashie (3.4.3)
|
35
37
|
highline (1.6.21)
|
36
38
|
i18n (0.6.11)
|
37
39
|
jeweler (2.0.1)
|
@@ -43,12 +45,12 @@ GEM
|
|
43
45
|
nokogiri (>= 1.5.10)
|
44
46
|
rake
|
45
47
|
rdoc
|
46
|
-
json (1.8.
|
47
|
-
jwt (1.2
|
48
|
-
minitest (5.
|
49
|
-
multi_json (1.11.
|
48
|
+
json (1.8.3)
|
49
|
+
jwt (1.5.2)
|
50
|
+
minitest (5.8.3)
|
51
|
+
multi_json (1.11.2)
|
50
52
|
multi_xml (0.5.5)
|
51
|
-
multipart-post (
|
53
|
+
multipart-post (2.0.0)
|
52
54
|
nokogiri (1.5.11)
|
53
55
|
oauth2 (1.0.0)
|
54
56
|
faraday (>= 0.8, < 0.10)
|
@@ -56,13 +58,13 @@ GEM
|
|
56
58
|
multi_json (~> 1.3)
|
57
59
|
multi_xml (~> 0.5)
|
58
60
|
rack (~> 1.2)
|
59
|
-
rack (1.6.
|
61
|
+
rack (1.6.4)
|
60
62
|
rake (10.4.2)
|
61
|
-
rdoc (4.2.
|
63
|
+
rdoc (4.2.1)
|
62
64
|
json (~> 1.4)
|
63
|
-
sqlite3 (1.3.
|
65
|
+
sqlite3 (1.3.11)
|
64
66
|
thor (0.19.1)
|
65
|
-
thread_safe (0.3.
|
67
|
+
thread_safe (0.3.5)
|
66
68
|
tzinfo (1.2.2)
|
67
69
|
thread_safe (~> 0.1)
|
68
70
|
|
@@ -79,3 +81,6 @@ DEPENDENCIES
|
|
79
81
|
nokogiri (~> 1.5.0)
|
80
82
|
rdoc (>= 2.4.2)
|
81
83
|
sqlite3
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.10.6
|
data/gemfiles/4.2.gemfile
CHANGED
data/gemfiles/4.2.gemfile.lock
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (4.2.
|
5
|
-
activesupport (= 4.2.
|
4
|
+
activemodel (4.2.4)
|
5
|
+
activesupport (= 4.2.4)
|
6
6
|
builder (~> 3.1)
|
7
|
-
activerecord (4.2.
|
8
|
-
activemodel (= 4.2.
|
9
|
-
activesupport (= 4.2.
|
7
|
+
activerecord (4.2.4)
|
8
|
+
activemodel (= 4.2.4)
|
9
|
+
activesupport (= 4.2.4)
|
10
10
|
arel (~> 6.0)
|
11
|
-
activesupport (4.2.
|
11
|
+
activesupport (4.2.4)
|
12
12
|
i18n (~> 0.7)
|
13
13
|
json (~> 1.7, >= 1.7.7)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
thread_safe (~> 0.3, >= 0.3.4)
|
16
16
|
tzinfo (~> 1.1)
|
17
|
-
addressable (2.
|
18
|
-
appraisal (1.0
|
17
|
+
addressable (2.4.0)
|
18
|
+
appraisal (2.1.0)
|
19
19
|
bundler
|
20
20
|
rake
|
21
21
|
thor (>= 0.14.0)
|
22
|
-
arel (6.0.
|
22
|
+
arel (6.0.3)
|
23
23
|
builder (3.2.2)
|
24
|
-
|
25
|
-
|
24
|
+
descendants_tracker (0.0.4)
|
25
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
26
|
+
faraday (0.9.2)
|
27
|
+
multipart-post (>= 1.2, < 3)
|
26
28
|
git (1.2.9.1)
|
27
|
-
github_api (0.
|
28
|
-
addressable
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
github_api (0.13.1)
|
30
|
+
addressable (~> 2.4.0)
|
31
|
+
descendants_tracker (~> 0.0.4)
|
32
|
+
faraday (~> 0.8, < 0.10)
|
33
|
+
hashie (>= 3.4)
|
34
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
35
|
oauth2
|
34
|
-
hashie (3.4.
|
36
|
+
hashie (3.4.3)
|
35
37
|
highline (1.6.21)
|
36
38
|
i18n (0.7.0)
|
37
39
|
jeweler (2.0.1)
|
@@ -43,12 +45,12 @@ GEM
|
|
43
45
|
nokogiri (>= 1.5.10)
|
44
46
|
rake
|
45
47
|
rdoc
|
46
|
-
json (1.8.
|
47
|
-
jwt (1.2
|
48
|
-
minitest (5.
|
49
|
-
multi_json (1.11.
|
48
|
+
json (1.8.3)
|
49
|
+
jwt (1.5.2)
|
50
|
+
minitest (5.8.3)
|
51
|
+
multi_json (1.11.2)
|
50
52
|
multi_xml (0.5.5)
|
51
|
-
multipart-post (
|
53
|
+
multipart-post (2.0.0)
|
52
54
|
nokogiri (1.5.11)
|
53
55
|
oauth2 (1.0.0)
|
54
56
|
faraday (>= 0.8, < 0.10)
|
@@ -56,13 +58,13 @@ GEM
|
|
56
58
|
multi_json (~> 1.3)
|
57
59
|
multi_xml (~> 0.5)
|
58
60
|
rack (~> 1.2)
|
59
|
-
rack (1.6.
|
61
|
+
rack (1.6.4)
|
60
62
|
rake (10.4.2)
|
61
|
-
rdoc (4.2.
|
63
|
+
rdoc (4.2.1)
|
62
64
|
json (~> 1.4)
|
63
|
-
sqlite3 (1.3.
|
65
|
+
sqlite3 (1.3.11)
|
64
66
|
thor (0.19.1)
|
65
|
-
thread_safe (0.3.
|
67
|
+
thread_safe (0.3.5)
|
66
68
|
tzinfo (1.2.2)
|
67
69
|
thread_safe (~> 0.1)
|
68
70
|
|
@@ -70,7 +72,7 @@ PLATFORMS
|
|
70
72
|
ruby
|
71
73
|
|
72
74
|
DEPENDENCIES
|
73
|
-
activerecord (~> 4.2.
|
75
|
+
activerecord (~> 4.2.3)
|
74
76
|
appraisal
|
75
77
|
highline (~> 1.6.0)
|
76
78
|
i18n (~> 0.7.0)
|
@@ -79,3 +81,6 @@ DEPENDENCIES
|
|
79
81
|
nokogiri (~> 1.5.0)
|
80
82
|
rdoc (>= 2.4.2)
|
81
83
|
sqlite3
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.10.6
|
data/lib/deep_cloneable.rb
CHANGED
@@ -48,6 +48,8 @@ class ActiveRecord::Base
|
|
48
48
|
if conditions_or_deep_associations.kind_of?(Hash)
|
49
49
|
conditions[:if] = conditions_or_deep_associations.delete(:if) if conditions_or_deep_associations[:if]
|
50
50
|
conditions[:unless] = conditions_or_deep_associations.delete(:unless) if conditions_or_deep_associations[:unless]
|
51
|
+
elsif conditions_or_deep_associations.kind_of?(Array)
|
52
|
+
conditions_or_deep_associations.delete_if {|entry| conditions.merge!(entry) if entry.is_a?(Hash) && (entry.key?(:if) || entry.key?(:unless)) }
|
51
53
|
end
|
52
54
|
|
53
55
|
dup_options = conditions_or_deep_associations.blank? ? {} : {:include => conditions_or_deep_associations}
|
data/readme.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# deep_cloneable
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/moiristo/deep_cloneable.svg?branch=master)](https://travis-ci.org/moiristo/deep_cloneable)
|
4
|
+
|
5
|
+
This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations. It is a rails 3+ upgrade of the [deep_cloning plugin](http://github.com/openminds/deep_cloning).
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.5 (tested)
|
10
|
+
* Activerecord 3.1, 3.2, 4.0, 4.1, 4.2 (tested)
|
11
|
+
* Rails 2.x/3.0 users, please check out the 'rails2.x-3.0' branch
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
* Add deep_cloneable to your Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'deep_cloneable', '~> 2.2.0'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Upgrading from v1
|
22
|
+
|
23
|
+
The `dup` method with arguments has been replaced in deep_cloneable 2 by the method `deep_clone`. Please update your sources accordingly.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
The `deep_clone` method supports a couple options that can be specified by passing an options hash. Without options, the behaviour is the same as ActiveRecord's [`dup`](http://apidock.com/rails/ActiveRecord/Core/dup) method.
|
28
|
+
|
29
|
+
### Association inclusion
|
30
|
+
|
31
|
+
Associations to be included in the dup can be specified with the `include` option:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# Single include
|
35
|
+
pirate.deep_clone include: :mateys
|
36
|
+
|
37
|
+
# Multiple includes
|
38
|
+
pirate.deep_clone include: [ :mateys, :treasures ]
|
39
|
+
|
40
|
+
# Deep includes
|
41
|
+
pirate.deep_clone include: { treasures: :gold_pieces }
|
42
|
+
pirate.deep_clone include: [ :mateys, { treasures: :gold_pieces } ]
|
43
|
+
|
44
|
+
# Disable validation for a performance speedup when saving the dup
|
45
|
+
pirate.deep_clone include: { treasures: :gold_pieces }, validate: false
|
46
|
+
|
47
|
+
# Conditional includes
|
48
|
+
pirate.deep_clone include: [
|
49
|
+
{
|
50
|
+
treasures: { gold_pieces: { if: lambda{|piece| piece.is_a?(Parrot) } } } },
|
51
|
+
mateys: { unless: lambda{|matey| matey.is_a?(GoldPiece) }
|
52
|
+
}
|
53
|
+
]
|
54
|
+
|
55
|
+
ship.deep_clone include: [
|
56
|
+
pirates: [ :treasures, :mateys, if: lambda {|pirate| pirate.name == 'Jack Sparrow' } ]
|
57
|
+
]
|
58
|
+
```
|
59
|
+
|
60
|
+
#### The Dictionary (Object Reusage)
|
61
|
+
|
62
|
+
The dictionary ensures that models are not duped multiple times when it is associated to nested models. It does this by storing a mapping of the original object to its duped object. It can be used as follows:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
# Enables the dictionary (empty on initialization)
|
66
|
+
pirate.deep_clone include: [ :mateys, { treasures: [ :matey, :gold_pieces ] } ], use_dictionary: true
|
67
|
+
|
68
|
+
# Deep clones with a prefilled dictionary
|
69
|
+
dictionary = { mateys: {} }
|
70
|
+
pirate.mateys.each{|m| dict[:mateys][m] = m.deep_clone }
|
71
|
+
pirate.deep_clone include: [ :mateys, { treasures: [ :matey, :gold_pieces ] } ], dictionary: dictionary
|
72
|
+
```
|
73
|
+
|
74
|
+
### Attribute Exceptions & Inclusions
|
75
|
+
|
76
|
+
The `deep_clone` method supports both `except` and `only` for specifying which attributes should be duped:
|
77
|
+
|
78
|
+
#### Exceptions
|
79
|
+
```ruby
|
80
|
+
# Single exception
|
81
|
+
pirate.deep_clone except: :name
|
82
|
+
|
83
|
+
# Multiple exceptions
|
84
|
+
pirate.deep_clone except: [ :name, :nick_name ]
|
85
|
+
|
86
|
+
# Nested exceptions
|
87
|
+
pirate.deep_clone include: :parrot, except: [ :name, { parrot: [ :name ] } ]
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Inclusions
|
91
|
+
```ruby
|
92
|
+
# Single attribute inclusion
|
93
|
+
pirate.deep_clone only: :name
|
94
|
+
|
95
|
+
# Multiple attribute inclusions
|
96
|
+
pirate.deep_clone only: [ :name, :nick_name ]
|
97
|
+
|
98
|
+
# Nested attribute inclusions
|
99
|
+
pirate.deep_clone include: :parrot, only: [ :name, { parrot: [ :name ] } ]
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
### Optional Block
|
104
|
+
|
105
|
+
Pass a block to `deep_clone` to modify a duped object after duplication:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
pirate.deep_clone include: :parrot do |original, kopy|
|
109
|
+
kopy.cloned_from_id = original.id if kopy.respond_to?(:cloned_from_id)
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
*Note*: Using `deep_clone` with a block will also pass the associated objects that are being cloned to the block, so be sure to check whether the object actually responds to your method of choice.
|
114
|
+
|
115
|
+
### Note on Patches/Pull Requests
|
116
|
+
|
117
|
+
* Fork the project.
|
118
|
+
* Make your feature addition or bug fix.
|
119
|
+
* Add tests for it. This is important so I don't break it in a
|
120
|
+
future version unintentionally.
|
121
|
+
* Commit, do not mess with rakefile, version, or history.
|
122
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
123
|
+
* Send me a pull request. Bonus points for topic branches.
|
124
|
+
|
125
|
+
### Copyright
|
126
|
+
|
127
|
+
Copyright © 2016 Reinier de Lange. See LICENSE for details.
|
data/test/test_deep_cloneable.rb
CHANGED
@@ -358,7 +358,19 @@ class TestDeepCloneable < MiniTest::Unit::TestCase
|
|
358
358
|
assert_equal 1, deep_clone.treasures.size
|
359
359
|
assert_equal 1, deep_clone.gold_pieces.size
|
360
360
|
assert_equal 0, deep_clone.mateys.size
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_should_reject_copies_if_conditionals_are_passed_with_associations
|
364
|
+
deep_clone = @ship.deep_clone(:include => [:pirates => [:treasures, :mateys, { :unless => lambda {|pirate| pirate.name == 'Jack Sparrow'} }]])
|
365
|
+
|
366
|
+
assert deep_clone.new_record?
|
367
|
+
assert deep_clone.save
|
368
|
+
assert_equal 0, deep_clone.pirates.size
|
361
369
|
|
370
|
+
deep_clone = @ship.deep_clone(:include => [:pirates => [:treasures, :mateys, { :if => lambda {|pirate| pirate.name == 'Jack Sparrow'} }]])
|
371
|
+
assert deep_clone.new_record?
|
372
|
+
assert deep_clone.save
|
373
|
+
assert_equal 1, deep_clone.pirates.size
|
362
374
|
end
|
363
375
|
|
364
376
|
def test_should_find_in_dict_for_habtm
|
@@ -378,10 +390,10 @@ class TestDeepCloneable < MiniTest::Unit::TestCase
|
|
378
390
|
]
|
379
391
|
}
|
380
392
|
],
|
381
|
-
:use_dictionary => true
|
382
|
-
|
393
|
+
:use_dictionary => true)
|
394
|
+
|
383
395
|
deep_clone.save!
|
384
|
-
|
396
|
+
|
385
397
|
assert_equal deep_clone.contractors.first.apartments.first.id, deep_clone.apartments.first.id
|
386
398
|
assert_equal deep_clone.apartments.first.contractors.first.id, deep_clone.contractors.first.id
|
387
399
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_cloneable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reinier de Lange
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.1.0
|
33
|
-
description: 'Extends the functionality of ActiveRecord::Base#
|
33
|
+
description: 'Extends the functionality of ActiveRecord::Base#dup to perform a deep
|
34
34
|
clone that includes user specified associations. '
|
35
35
|
email: r.j.delange@nedforce.nl
|
36
36
|
executables: []
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files:
|
39
39
|
- LICENSE
|
40
|
-
-
|
40
|
+
- readme.md
|
41
41
|
files:
|
42
42
|
- ".document"
|
43
43
|
- ".travis.yml"
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- Gemfile
|
46
46
|
- Gemfile.lock
|
47
47
|
- LICENSE
|
48
|
-
- README.rdoc
|
49
48
|
- Rakefile
|
50
49
|
- VERSION
|
51
50
|
- deep_cloneable.gemspec
|
@@ -61,6 +60,7 @@ files:
|
|
61
60
|
- gemfiles/4.2.gemfile.lock
|
62
61
|
- init.rb
|
63
62
|
- lib/deep_cloneable.rb
|
63
|
+
- readme.md
|
64
64
|
- test/database.yml
|
65
65
|
- test/models.rb
|
66
66
|
- test/schema.rb
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.4.
|
89
|
+
rubygems_version: 2.4.8
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: This gem gives every ActiveRecord::Base object the possibility to do a deep
|
data/README.rdoc
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
= Deep_cloneable
|
2
|
-
|
3
|
-
{<img src="https://travis-ci.org/moiristo/deep_cloneable.png?branch=master" alt="Build Status" />}[https://travis-ci.org/moiristo/deep_cloneable]
|
4
|
-
|
5
|
-
This gem gives every ActiveRecord::Base object the possibility to do a deep clone. It is a rails3 upgrade of the deep_cloning plugin (http://github.com/openminds/deep_cloning).
|
6
|
-
|
7
|
-
== Requirements
|
8
|
-
|
9
|
-
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.5 (tested)
|
10
|
-
|
11
|
-
* Activerecord 3.1, 3.2, 4.0, 4.1, 4.2
|
12
|
-
|
13
|
-
* Rails 2.x/3.0 users, please check out the 'rails2.x-3.0' branch.
|
14
|
-
|
15
|
-
== Installation
|
16
|
-
|
17
|
-
* In your Gemfile:
|
18
|
-
|
19
|
-
gem 'deep_cloneable', '~> 2.1.1'
|
20
|
-
|
21
|
-
== Upgrading from v1
|
22
|
-
|
23
|
-
The 'dup' method with arguments has been replaced in deep_cloneable 2 by the method 'deep_clone'. Please update your sources accordingly.
|
24
|
-
|
25
|
-
== Example
|
26
|
-
|
27
|
-
=== Cloning one single association
|
28
|
-
pirate.deep_clone :include => :mateys
|
29
|
-
|
30
|
-
=== Cloning multiple associations
|
31
|
-
pirate.deep_clone :include => [:mateys, :treasures]
|
32
|
-
|
33
|
-
=== Cloning really deep
|
34
|
-
pirate.deep_clone :include => {:treasures => :gold_pieces}
|
35
|
-
|
36
|
-
=== Cloning really deep with multiple associations
|
37
|
-
pirate.deep_clone :include => [:mateys, {:treasures => :gold_pieces}]
|
38
|
-
|
39
|
-
=== Cloning really deep with multiple associations and a dictionary
|
40
|
-
|
41
|
-
A dictionary ensures that models are not cloned multiple times when it is associated to nested models.
|
42
|
-
When using a dictionary, ensure recurring associations are cloned first:
|
43
|
-
|
44
|
-
pirate.deep_clone :include => [:mateys, {:treasures => [:matey, :gold_pieces]}], :use_dictionary => true
|
45
|
-
|
46
|
-
If this is not an option for you, it is also possible to populate the dictionary manually in advance:
|
47
|
-
|
48
|
-
dict = { :mateys => {} }
|
49
|
-
pirate.mateys.each{|m| dict[:mateys][m] = m.deep_clone }
|
50
|
-
pirate.deep_clone :include => [:mateys, {:treasures => [:matey, :gold_pieces]}], :dictionary => dict
|
51
|
-
|
52
|
-
When an object isn't found in the dictionary, it will be populated. By passing in an empty dictionary you can populate it automatically and reuse it in subsequent deep_clones to avoid creating multiples of the same object where you have overlapping associations.
|
53
|
-
|
54
|
-
=== Cloning a model without an attribute
|
55
|
-
pirate.deep_clone :except => :name
|
56
|
-
|
57
|
-
=== Cloning a model without multiple attributes
|
58
|
-
pirate.deep_clone :except => [:name, :nick_name]
|
59
|
-
|
60
|
-
=== Cloning a model without an attribute or nested multiple attributes
|
61
|
-
pirate.deep_clone :include => :parrot, :except => [:name, { :parrot => [:name] }]
|
62
|
-
|
63
|
-
=== Cloning with a block
|
64
|
-
pirate.deep_clone :include => :parrot do |original, kopy|
|
65
|
-
kopy.cloned_from_id = original.id if kopy.respond_to?(:cloned_from_id)
|
66
|
-
end
|
67
|
-
|
68
|
-
*Note*: Using deep_clone with a block will also pass the associated objects that are being cloned to the block,
|
69
|
-
so be sure to check whether the object actually responds to your method of choice.
|
70
|
-
|
71
|
-
=== Cloning without validations
|
72
|
-
pirate.deep_clone :include => {:treasures => :gold_pieces}, :validate => false
|
73
|
-
|
74
|
-
=== Cloning a model with only explicitly assigned attribute
|
75
|
-
pirate.deep_clone :only => :name
|
76
|
-
|
77
|
-
=== Cloning a model with only multiple explicitly assigned attributes
|
78
|
-
pirate.deep_clone :only => [:name, :nick_name]
|
79
|
-
|
80
|
-
=== Cloning a model with explicitly assigned attributes or nested multiple attributes
|
81
|
-
pirate.deep_clone :include => :parrot, :only => [:name, { :parrot => [:name] }]
|
82
|
-
|
83
|
-
=== Conditional cloning
|
84
|
-
pirate.deep_clone(:include => [{:treasures => { :gold_pieces => { :if => lambda{|piece| piece.is_a?(Parrot) } } } }, :mateys => { :unless => lambda{|matey| matey.is_a?(GoldPiece) } } ])
|
85
|
-
|
86
|
-
== Note on Patches/Pull Requests
|
87
|
-
|
88
|
-
* Fork the project.
|
89
|
-
* Make your feature addition or bug fix.
|
90
|
-
* Add tests for it. This is important so I don't break it in a
|
91
|
-
future version unintentionally.
|
92
|
-
* Commit, do not mess with rakefile, version, or history.
|
93
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
94
|
-
* Send me a pull request. Bonus points for topic branches.
|
95
|
-
|
96
|
-
== Copyright
|
97
|
-
|
98
|
-
Copyright (c) 2015 Reinier de Lange. See LICENSE for details.
|