activerecord_cloneable 0.3.18 → 0.3.19
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 +14 -9
- 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: 372b3e2ed2da681cd149b3230d2755e927ecd4a9
|
4
|
+
data.tar.gz: 6c0e1b48c33560720bc88f5e5077680d503846d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387b08caa5adce589bcb61d197d0ac60e6d8be98ba79fac7de0f8357ce3e0faa4897fe79f96b925ed1bb50027ba26dee5b7b805f362e0a272602f5ba095b0f64
|
7
|
+
data.tar.gz: a09afb78e287904e538c7487108e73a9392559982546e84922f8742b1863030e0aff3810242dceef8a333123ac2cc744a4aadf969cd6465f9951dab94d6f0ac5
|
@@ -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.19'
|
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'
|
@@ -59,11 +59,7 @@ module ActiveRecord::Cloneable
|
|
59
59
|
shared_parent_relations: find_applicable_clone_args( parent_relation.name, args[:shared_parent_relations] )
|
60
60
|
)
|
61
61
|
rescue NoMethodError => ex
|
62
|
-
|
63
|
-
raise "#{obj.class.name} objects do not know how to clone themselves; they should be marked as cloneable or skipped."
|
64
|
-
else
|
65
|
-
raise ex
|
66
|
-
end
|
62
|
+
handle_cloneable_exception(ex, "#{obj.class.name} objects do not know how to clone themselves; they should be marked as cloneable or skipped.")
|
67
63
|
end
|
68
64
|
cloned_record.send( "#{parent_relation.name}=", rec )
|
69
65
|
end
|
@@ -134,8 +130,8 @@ module ActiveRecord::Cloneable
|
|
134
130
|
begin
|
135
131
|
cloned_child_record = child_record.clone_record( child_args )
|
136
132
|
cloned_record.send( child_relation.name ) << cloned_child_record
|
137
|
-
rescue NoMethodError
|
138
|
-
|
133
|
+
rescue NoMethodError => ex
|
134
|
+
handle_cloneable_exception(ex, "#{child_record.class.name} objects do not know how to clone themselves; they should be marked as cloneable or skipped. (#{self.class.name} / #{child_relation.name}")
|
139
135
|
end
|
140
136
|
end
|
141
137
|
end
|
@@ -156,11 +152,20 @@ module ActiveRecord::Cloneable
|
|
156
152
|
begin
|
157
153
|
cloned_child_record = kid.clone_record( child_args )
|
158
154
|
cloned_record.send( "#{child_relation.name}=", cloned_child_record )
|
159
|
-
rescue NoMethodError
|
160
|
-
|
155
|
+
rescue NoMethodError => ex
|
156
|
+
handle_cloneable_exception(ex, "#{kid.class.name} objects do not know how to clone themselves; they should be marked as cloneable or skipped. (#{self.class.name} / #{child_relation.name} -- #{args[:stack].inspect}")
|
161
157
|
end
|
162
158
|
end
|
163
159
|
return cloned_record
|
164
160
|
end
|
161
|
+
|
162
|
+
def handle_cloneable_exception(ex, msg)
|
163
|
+
if ex.name.to_sym == :clone_record
|
164
|
+
raise msg
|
165
|
+
else
|
166
|
+
raise ex
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
165
170
|
end
|
166
171
|
end
|