Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Dec 3, 2018
1 parent 1b5af7f commit 5f088e6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions app/models/whois_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,13 @@ def generate_json
h[:admin_contacts] = []

domain.admin_contacts.each do |contact|
h[:admin_contacts] << {
name: contact.name,
email: contact.email,
changed: contact.updated_at.try(:to_s, :iso8601),
disclosed_attributes: contact.disclosed_attributes,
}
h[:admin_contacts] << contact_json_hash(contact)
end

h[:tech_contacts] = []

domain.tech_contacts.each do |contact|
h[:tech_contacts] << {
name: contact.name,
email: contact.email,
changed: contact.updated_at.try(:to_s, :iso8601),
disclosed_attributes: contact.disclosed_attributes,
}
h[:tech_contacts] << contact_json_hash(contact)
end

# update registar triggers when adding new attributes
Expand Down Expand Up @@ -123,4 +113,13 @@ def destroy_whois_record
def disclaimer_text
Setting.registry_whois_disclaimer
end

def contact_json_hash(contact)
{
name: contact.name,
email: contact.email,
changed: contact.updated_at.try(:to_s, :iso8601),
disclosed_attributes: contact.disclosed_attributes,
}
end
end

0 comments on commit 5f088e6

Please sign in to comment.