mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Extract block to helper function
This commit is contained in:
parent
b0bec41f56
commit
a93228c579
4 changed files with 14 additions and 8 deletions
10
app/helpers/object_versions_helper.rb
Normal file
10
app/helpers/object_versions_helper.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module ObjectVersionsHelper
|
||||
def attach_existing_fields(version, new_object)
|
||||
version.object_changes.to_h.each do |k, v|
|
||||
method_name = "#{k}=".to_sym
|
||||
if new_object.respond_to?(method_name)
|
||||
new_object.public_send(method_name, v.last)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue