deep_cloneable 1.7.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +1 -2
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/deep_cloneable.gemspec +6 -9
- data/gemfiles/3.1.gemfile +0 -1
- data/gemfiles/3.1.gemfile.lock +0 -1
- data/gemfiles/3.2.gemfile +0 -1
- data/gemfiles/3.2.gemfile.lock +0 -1
- data/gemfiles/4.0.gemfile +0 -1
- data/gemfiles/4.0.gemfile.lock +0 -1
- data/gemfiles/4.1.gemfile +0 -1
- data/gemfiles/4.1.gemfile.lock +0 -1
- data/lib/deep_cloneable.rb +2 -21
- data/test/test_deep_cloneable.rb +0 -11
- metadata +7 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db1696a5b12a6de3c8780ae4eabaf94531dc7213
|
4
|
+
data.tar.gz: 392237ca46af2ff5c40e19b03988fc4c092fec89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6925639f7cb22d67cd55e24357df3a1f9a53093f0547c2e6bb0e56b268868c31eb8695b675b2b6f81dd16a750e0b4c6702aec2605b73efbfecfd5b546525925
|
7
|
+
data.tar.gz: b53468ac2757bc8149fe40b50732e85ed618e14803d95d7c95489f9bbd4a5b31bf71118f3d233f553f946593f997cc26b39d634fa454015748f963b4f81f5829
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -16,11 +16,11 @@ This gem gives every ActiveRecord::Base object the possibility to do a deep clon
|
|
16
16
|
|
17
17
|
* In your Gemfile:
|
18
18
|
|
19
|
-
gem 'deep_cloneable', '~>
|
19
|
+
gem 'deep_cloneable', '~> 2.0.0'
|
20
20
|
|
21
|
-
==
|
21
|
+
== Upgrading from v1
|
22
22
|
|
23
|
-
|
23
|
+
The 'dup' method with arguments has been replaced in deep_cloneable 2 by the method 'deep_clone'. Please update your sources accordingly.
|
24
24
|
|
25
25
|
== Example
|
26
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/deep_cloneable.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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
|
5
|
+
# stub: deep_cloneable 2.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "deep_cloneable"
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.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 = "2014-06-
|
14
|
+
s.date = "2014-06-26"
|
15
15
|
s.description = "Extends the functionality of ActiveRecord::Base#clone 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 = [
|
@@ -53,15 +53,12 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.specification_version = 4
|
54
54
|
|
55
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
-
s.add_runtime_dependency(%q<activerecord>, [">= 3.1.0"])
|
57
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 3.1.0"])
|
56
|
+
s.add_runtime_dependency(%q<activerecord>, ["< 5.0.0", ">= 3.1.0"])
|
58
57
|
else
|
59
|
-
s.add_dependency(%q<activerecord>, [">= 3.1.0"])
|
60
|
-
s.add_dependency(%q<activesupport>, [">= 3.1.0"])
|
58
|
+
s.add_dependency(%q<activerecord>, ["< 5.0.0", ">= 3.1.0"])
|
61
59
|
end
|
62
60
|
else
|
63
|
-
s.add_dependency(%q<activerecord>, [">= 3.1.0"])
|
64
|
-
s.add_dependency(%q<activesupport>, [">= 3.1.0"])
|
61
|
+
s.add_dependency(%q<activerecord>, ["< 5.0.0", ">= 3.1.0"])
|
65
62
|
end
|
66
63
|
end
|
67
64
|
|
data/gemfiles/3.1.gemfile
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
data/gemfiles/3.2.gemfile
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
data/gemfiles/4.0.gemfile
CHANGED
data/gemfiles/4.0.gemfile.lock
CHANGED
data/gemfiles/4.1.gemfile
CHANGED
data/gemfiles/4.1.gemfile.lock
CHANGED
data/lib/deep_cloneable.rb
CHANGED
@@ -1,21 +1,6 @@
|
|
1
1
|
class ActiveRecord::Base
|
2
2
|
module DeepCloneable
|
3
3
|
|
4
|
-
if ActiveRecord::VERSION::MAJOR < 4
|
5
|
-
ActiveRecord::Base.class_eval do
|
6
|
-
protected :initialize_dup
|
7
|
-
module Dup
|
8
|
-
def dup
|
9
|
-
copy = super
|
10
|
-
copy.send(:initialize_dup, self)
|
11
|
-
copy
|
12
|
-
end
|
13
|
-
end
|
14
|
-
remove_possible_method :dup
|
15
|
-
include Dup
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
4
|
# Deep dups an ActiveRecord model. See README.rdoc
|
20
5
|
def deep_clone *args, &block
|
21
6
|
options = args[0] || {}
|
@@ -91,12 +76,6 @@ class ActiveRecord::Base
|
|
91
76
|
return kopy
|
92
77
|
end
|
93
78
|
|
94
|
-
def dup *args, &block
|
95
|
-
return super() if args.empty? && !block
|
96
|
-
ActiveSupport::Deprecation.warn("Calling dup with arguments or blocks is deprecated and will be removed in deep_cloneable 2. Use method 'deep_clone' instead.")
|
97
|
-
deep_clone *args, &block
|
98
|
-
end
|
99
|
-
|
100
79
|
private
|
101
80
|
|
102
81
|
def dup_belongs_to_association options, &block
|
@@ -146,6 +125,8 @@ class ActiveRecord::Base
|
|
146
125
|
end
|
147
126
|
|
148
127
|
class AssociationNotFoundException < StandardError; end
|
128
|
+
|
129
|
+
ActiveRecord::Base.class_eval { protected :initialize_dup } if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 1
|
149
130
|
end
|
150
131
|
|
151
132
|
include DeepCloneable
|
data/test/test_deep_cloneable.rb
CHANGED
@@ -339,15 +339,4 @@ class TestDeepCloneable < MiniTest::Unit::TestCase
|
|
339
339
|
assert_equal 'John', deep_clone.mateys.first.name
|
340
340
|
end
|
341
341
|
|
342
|
-
def test_should_deep_clone_via_dup
|
343
|
-
deep_clone = @jack.dup(:include => :parrot) do |original, kopy|
|
344
|
-
kopy.cloned_from_id = original.id
|
345
|
-
end
|
346
|
-
|
347
|
-
assert deep_clone.new_record?
|
348
|
-
assert deep_clone.save
|
349
|
-
assert_equal @jack.id, deep_clone.cloned_from_id
|
350
|
-
assert_equal @jack.parrot.id, deep_clone.parrot.cloned_from_id
|
351
|
-
end
|
352
|
-
|
353
342
|
end
|
metadata
CHANGED
@@ -1,33 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_cloneable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.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: 2014-06-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 3.1.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
19
|
+
version: 5.0.0
|
31
20
|
- - ">="
|
32
21
|
- !ruby/object:Gem::Version
|
33
22
|
version: 3.1.0
|
@@ -35,6 +24,9 @@ dependencies:
|
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
27
|
+
- - "<"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.0.0
|
38
30
|
- - ">="
|
39
31
|
- !ruby/object:Gem::Version
|
40
32
|
version: 3.1.0
|