deep_cloneable 1.3.0 → 1.3.1

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.
@@ -4,61 +4,51 @@ This gem gives every ActiveRecord::Base object the possibility to do a deep clon
4
4
 
5
5
  == Requirements
6
6
 
7
- * Activerecord, tested with AR 3 & 3.1.
7
+ * Activerecord 3.1, 3.2
8
8
 
9
- == Installation
10
-
11
- * Install by adding the gem to your Gemfile
12
-
13
- gem 'deep_cloneable'
14
-
15
- * Rails 2:
9
+ * Rails 2.x/3.0 users, please check out the 'rails2.x-3.0' branch.
16
10
 
17
- gem install deep_cloneable
18
-
19
- And include the gem in your apps config
20
-
21
- config.gem 'deep_cloneable'
11
+ == Installation
22
12
 
23
- * Or install as a plugin if you must:
13
+ * In your Gemfile:
24
14
 
25
- ./script/plugin install git://github.com/moiristo/deep_cloneable.git
15
+ gem 'deep_cloneable', '~> 1.3.1'
26
16
 
27
17
  == Example
28
18
 
29
19
  === Cloning one single association
30
- pirate.clone :include => :mateys
20
+ pirate.dup :include => :mateys
31
21
 
32
22
  === Cloning multiple associations
33
- pirate.clone :include => [:mateys, :treasures]
23
+ pirate.dup :include => [:mateys, :treasures]
34
24
 
35
25
  === Cloning really deep
36
- pirate.clone :include => {:treasures => :gold_pieces}
26
+ pirate.dup :include => {:treasures => :gold_pieces}
37
27
 
38
28
  === Cloning really deep with multiple associations
39
- pirate.clone :include => [:mateys, {:treasures => :gold_pieces}]
29
+ pirate.dup :include => [:mateys, {:treasures => :gold_pieces}]
40
30
 
41
31
  === Cloning really deep with multiple associations and a dictionary
42
32
 
43
33
  A dictionary ensures that models are not cloned multiple times when it is associated to nested models.
44
34
  When using a dictionary, ensure recurring associations are cloned first:
45
35
 
46
- pirate.clone :include => [:mateys, {:treasures => [:matey, :gold_pieces], :use_dictionary => true }]
36
+ pirate.dup :include => [:mateys, {:treasures => [:matey, :gold_pieces], :use_dictionary => true }]
47
37
 
48
38
  If this is not an option for you, it is also possible to populate the dictionary manually in advance:
49
39
 
50
40
  dict = { :mateys => {} }
51
- pirate.mateys.each{|m| dict[:mateys][m] = m.clone }
52
- pirate.clone :include => [:mateys, {:treasures => [:matey, :gold_pieces], :dictionary => dict }]
41
+ pirate.mateys.each{|m| dict[:mateys][m] = m.dup }
42
+ pirate.dup :include => [:mateys, {:treasures => [:matey, :gold_pieces], :dictionary => dict }]
53
43
 
54
44
  === Cloning a model without an attribute
55
- pirate.clone :except => :name
45
+ pirate.dup :except => :name
56
46
 
57
47
  === Cloning a model without multiple attributes
58
- pirate.clone :except => [:name, :nick_name]
48
+ pirate.dup :except => [:name, :nick_name]
59
49
 
60
50
  === Cloning a model without an attribute or nested multiple attributes
61
- pirate.clone :include => :parrot, :except => [:name, { :parrot => [:name] }]
51
+ pirate.dup :include => :parrot, :except => [:name, { :parrot => [:name] }]
62
52
 
63
53
  == Contributors
64
54
 
@@ -78,4 +68,4 @@ If this is not an option for you, it is also possible to populate the dictionary
78
68
 
79
69
  == Copyright
80
70
 
81
- Copyright (c) 2011 Reinier de Lange. See LICENSE for details.
71
+ Copyright (c) 2012 Reinier de Lange. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deep_cloneable}
8
- s.version = "1.3.0"
8
+ s.version = "1.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Reinier de Lange"]
12
- s.date = %q{2011-07-11}
11
+ s.authors = [%q{Reinier de Lange}]
12
+ s.date = %q{2012-01-26}
13
13
  s.description = %q{Extends the functionality of ActiveRecord::Base#clone to perform a deep clone that includes user specified associations. }
14
14
  s.email = %q{r.j.delange@nedforce.nl}
15
15
  s.extra_rdoc_files = [
@@ -31,8 +31,8 @@ Gem::Specification.new do |s|
31
31
  "test/test_helper.rb"
32
32
  ]
33
33
  s.homepage = %q{http://github.com/moiristo/deep_cloneable}
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.6.2}
34
+ s.require_paths = [%q{lib}]
35
+ s.rubygems_version = %q{1.8.6}
36
36
  s.summary = %q{This gem gives every ActiveRecord::Base object the possibility to do a deep clone.}
37
37
 
38
38
  if s.respond_to? :specification_version then
@@ -60,7 +60,7 @@ class ActiveRecord::Base
60
60
  if options[:except]
61
61
  exceptions = options[:except].nil? ? [] : [options[:except]].flatten
62
62
  exceptions.each do |attribute|
63
- kopy.send(:write_attribute, attribute, attributes_from_column_definition[attribute.to_s]) unless attribute.kind_of?(Hash)
63
+ kopy.send(:write_attribute, attribute, self.class.column_defaults.dup[attribute.to_s]) unless attribute.kind_of?(Hash)
64
64
  end
65
65
  deep_exceptions = exceptions.select{|e| e.kind_of?(Hash) }.inject({}){|m,h| m.merge(h) }
66
66
  end
@@ -4,6 +4,7 @@ ActiveRecord::Schema.define(:version => 1) do
4
4
  t.column :nick_name, :string, :default => 'no nickname'
5
5
  t.column :age, :string
6
6
  t.column :ship_id, :integer
7
+ t.column :ship_type, :string
7
8
  end
8
9
 
9
10
  create_table :parrots, :force => true do |t|
@@ -5,7 +5,6 @@ require 'pp'
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
7
 
8
- Gem.activate 'activerecord'
9
8
  require 'active_record'
10
9
  require File.dirname(__FILE__) + '/../init.rb'
11
10
 
metadata CHANGED
@@ -1,34 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: deep_cloneable
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.1
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 0
10
- version: 1.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Reinier de Lange
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-11 00:00:00 +02:00
19
- default_executable:
12
+ date: 2012-01-26 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: "Extends the functionality of ActiveRecord::Base#clone to perform a deep clone that includes user specified associations. "
14
+ description: ! 'Extends the functionality of ActiveRecord::Base#clone to perform a
15
+ deep clone that includes user specified associations. '
23
16
  email: r.j.delange@nedforce.nl
24
17
  executables: []
25
-
26
18
  extensions: []
27
-
28
- extra_rdoc_files:
19
+ extra_rdoc_files:
29
20
  - LICENSE
30
21
  - README.rdoc
31
- files:
22
+ files:
32
23
  - .document
33
24
  - LICENSE
34
25
  - README.rdoc
@@ -41,39 +32,29 @@ files:
41
32
  - test/schema.rb
42
33
  - test/test_deep_cloneable.rb
43
34
  - test/test_helper.rb
44
- has_rdoc: true
45
35
  homepage: http://github.com/moiristo/deep_cloneable
46
36
  licenses: []
47
-
48
37
  post_install_message:
49
38
  rdoc_options: []
50
-
51
- require_paths:
39
+ require_paths:
52
40
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
41
+ required_ruby_version: !ruby/object:Gem::Requirement
54
42
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
48
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
- version: "0"
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
71
53
  requirements: []
72
-
73
54
  rubyforge_project:
74
- rubygems_version: 1.6.2
55
+ rubygems_version: 1.8.6
75
56
  signing_key:
76
57
  specification_version: 3
77
- summary: This gem gives every ActiveRecord::Base object the possibility to do a deep clone.
58
+ summary: This gem gives every ActiveRecord::Base object the possibility to do a deep
59
+ clone.
78
60
  test_files: []
79
-