mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Refactored contact attribute assignment
This commit is contained in:
parent
5b91acb343
commit
6bcf508fac
7 changed files with 94 additions and 33 deletions
|
@ -67,6 +67,32 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
class << self
|
||||
|
||||
def extract_attributes ph, type=:create
|
||||
|
||||
contact_hash = {
|
||||
#code: ph[:id],
|
||||
phone: ph[:voice],
|
||||
ident: ph[:ident],
|
||||
#ident_type: ident_type,
|
||||
email: ph[:email]
|
||||
}
|
||||
|
||||
contact_hash = contact_hash.merge({
|
||||
name: ph[:postalInfo][:name],
|
||||
org_name: ph[:postalInfo][:org]
|
||||
}) if ph[:postalInfo].is_a? Hash
|
||||
|
||||
contact_hash[:code] = ph[:id] if type == :create
|
||||
|
||||
contact_hash.delete_if { |k, v| v.nil? }
|
||||
end
|
||||
|
||||
|
||||
def ident_type code
|
||||
|
||||
end
|
||||
|
||||
def check_availability(codes)
|
||||
codes = [codes] if codes.is_a?(String)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue