activerecord_cloneable 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/activerecord_cloneable.gemspec +1 -1
- data/lib/active_record/cloneable.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b66fcdf4da4ca6c0d44857a2a166f6369a88d74a
|
4
|
+
data.tar.gz: 3e60a5212d3beb3991783384dce29e49d03220df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c12b2f882f533c3bbd0e8ebc7140954da47502f1a1563f8d20d4f5a0e5b9150725cf1f8954ade04fdf6a57a9427f08da8dc7d087596336a06f04922598e26ed
|
7
|
+
data.tar.gz: f5cc237524c960efaab035b891436c97bd8800f0c863c4a180eea523139311fe6546080af2dfce854b7762ccc462285778f7c054bcf2f932756aacdbc957a520
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'activerecord_cloneable'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.8'
|
4
4
|
s.summary = "A library to help clone active records - that is, generate active new record objects with the data copied from an existing record."
|
5
5
|
s.authors = ["Adam Palmblad"]
|
6
6
|
s.email = 'apalmblad@gmail.com'
|
@@ -42,6 +42,7 @@ module ActiveRecord::Cloneable
|
|
42
42
|
def clone_belongs_to_relations( relations, cloned_record, args )
|
43
43
|
return if relations.nil?
|
44
44
|
relations.each do |parent_relation|
|
45
|
+
puts "Cloning #{parent_relation.name} with #{child_args}"
|
45
46
|
obj = send( parent_relation.name )
|
46
47
|
next if obj.nil?
|
47
48
|
next if args[:skipped_children].include?( obj )
|
@@ -89,7 +90,6 @@ module ActiveRecord::Cloneable
|
|
89
90
|
end
|
90
91
|
# ---------------------------------------------------------------------- clone
|
91
92
|
def clone_record( args = {} )
|
92
|
-
puts "Cloning #{parent_relation.name} with #{args.inspect}"
|
93
93
|
args[:shared_parent_relations] ||= []
|
94
94
|
args[:skipped_child_relations] ||= []
|
95
95
|
args[:cloned_parents] ||= []
|
@@ -127,6 +127,7 @@ module ActiveRecord::Cloneable
|
|
127
127
|
# child_args[:attributes][child_relation.primary_key_name.to_sym] = nil
|
128
128
|
#end
|
129
129
|
begin
|
130
|
+
puts "Cloning #{child_relation.name} with #{child_args}"
|
130
131
|
cloned_child_record = child_record.clone_record( child_args )
|
131
132
|
cloned_record.send( child_relation.name ) << cloned_child_record
|
132
133
|
rescue NoMethodError
|
@@ -148,6 +149,7 @@ module ActiveRecord::Cloneable
|
|
148
149
|
stack: args[:stack] + [ child_relation.name ] ,
|
149
150
|
skipped_child_relations: args[:skipped_child_relations].find_all{ |x| x.is_a?( Hash ) && x[child_relation.name.to_sym] }.map{ |x| x.values }.flatten }
|
150
151
|
begin
|
152
|
+
puts "Cloning #{child_relation.name} with #{child_args}"
|
151
153
|
cloned_child_record = kid.clone_record( child_args )
|
152
154
|
cloned_record.send( "#{child_relation.name}=", cloned_child_record )
|
153
155
|
rescue NoMethodError
|