From 015a65d7c64e45f7960967b506f767a59bff3a3f Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 17 Feb 2015 10:32:40 +0200 Subject: [PATCH] Legaldocument for contact update --- app/models/epp/contact.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index fa11c2663..62a052077 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -33,14 +33,9 @@ class Epp::Contact < Contact sat[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present? at.delete(:address_attributes) if at[:address_attributes].blank? - legald = f.css('legalDocument').first - if legald.present? - at[:legal_documents_attributes] = {}.with_indifferent_access - lat = at[:legal_documents_attributes] - lat[0] = {}.with_indifferent_access - lat[0][:document_type] = legald['type'] - lat[0][:body] = legald.text - at.delete(:legal_documents_attributes) if at[:legal_documents_attributes].blank? + legal_frame = f.css('legalDocument').first + if legal_frame.present? + at[:legal_documents_attributes] = legal_document_attrs(legal_frame) end at @@ -53,6 +48,14 @@ class Epp::Contact < Contact return super if frame.blank? super(attrs_from(frame)) end + + def legal_document_attrs(legal_frame) + attrs = {}.with_indifferent_access + attrs[0] = {}.with_indifferent_access + attrs[0][:document_type] = legal_frame['type'] + attrs[0][:body] = legal_frame + attrs + end end def epp_code_map # rubocop:disable Metrics/MethodLength @@ -75,6 +78,9 @@ class Epp::Contact < Contact return super if frame.blank? at = {}.with_indifferent_access at.deep_merge!(self.class.attrs_from(frame.css('chg'))) + legal_frame = frame.css('legalDocument').first + at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame) + super(at) end end