activerecord_cloneable 0.3.18 → 0.3.19

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 428ebbe990a15ce662d0888d493b41f63a56e5d4
4
- data.tar.gz: c3d397cdfc817187469df50427b77fdee34826b4
3
+ metadata.gz: 372b3e2ed2da681cd149b3230d2755e927ecd4a9
4
+ data.tar.gz: 6c0e1b48c33560720bc88f5e5077680d503846d2
5
5
  SHA512:
6
- metadata.gz: 39557885a61101911f370e24ef52c6bd16c87105963e7c4742cc12756376e7ae73f45ccfc82dba1f4cbcedccceaea00fed130504f8a553c76e00c73f61c955b4
7
- data.tar.gz: eb7c68b3f3d6947b7066d975d23faec02ddb8529300c07b7c942c8d76993ff99a20f0db455f4c029a32543643c717a0bbfebb2965da566a3d06cafa7f69e6846
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.18'
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
- if ex.name.to_sym == :clone_record
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
- raise "#{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}"
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
- raise "#{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}"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_cloneable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.18
4
+ version: 0.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Palmblad