Use model accessors explicitly instead of #[]

#660
This commit is contained in:
Artur Beljajev 2018-01-30 19:33:00 +02:00
parent 762f891b84
commit cefa37d081
5 changed files with 6 additions and 6 deletions

View file

@ -67,7 +67,7 @@ module Versions
map do |ver|
o = new(ver.object)
o.version_loader = ver
ver.object_changes.to_h.each { |k, v| o[k]=v[-1] }
ver.object_changes.to_h.each { |k, v| o.public_send("#{k}=", v[-1]) }
o
end
not_in_history = where(id: (ids.to_a - from_history.map(&:id)))

View file

@ -58,7 +58,7 @@
- @versions.each do |version|
- if version
- contact = Contact.new(version.object.to_h)
- version.object_changes.to_h.each{|k,v| contact[k]=v.last}
- version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last) }
%tr
%td= link_to(contact.name, admin_contact_version_path(version.id))

View file

@ -1,5 +1,5 @@
- contact = Contact.new(@version.object.to_h)
- @version.object_changes.to_h.each{|k,v| contact[k]=v.last}
- @version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last ) }
= render 'shared/title', name: contact.name
.row

View file

@ -56,7 +56,7 @@
- @versions.each do |version|
- if version
- domain = Domain.new(version.object.to_h)
- version.object_changes.to_h.each{|k,v| domain[k]=v.last}
- version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) }
%tr
%td= link_to(domain.name, admin_domain_version_path(version.id))
@ -66,7 +66,7 @@
- else
- contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first
- if contact.nil? && ver = ContactVersion.where(item_id: domain.registrant_id).last
- contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}){|(k,v), o| o[k]=v.last } ))
- contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}){|(k,v), o| o.public_send("#{k}=", v.last) } ))
= contact.try(:name)
= " ".html_safe
= "(#{t(:deleted)})"

View file

@ -1,5 +1,5 @@
- domain = Domain.new(@version.object.to_h)
- @version.object_changes.to_h.each{|k,v| domain[k]=v.last}
- @version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) }
- if @version
- children = HashWithIndifferentAccess.new(@version.children)