Class: AeUsersMigrator::Import::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/ae_users_migrator/import.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Person

Returns a new instance of Person.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ae_users_migrator/import.rb', line 49

def initialize(json)
  @email_addresses = json["email_addresses"].collect do |ea_record|
    EmailAddress.new(ea_record["email_address"] || ea_record)
  end
  
  @open_id_identities = json["open_id_identities"].collect do |oid_record|
    OpenIdIdentity.new(oid_record["open_id_identity"] || oid_record)
  end
  
  @roles = json["roles"].collect do |role_record|
    rr = 
    Role.new(role_record["role"] || role_record)
  end
  
  if json["account"]
    @account = Account.new(json["account"]["account"] || json["account"])
  end
  
  %w{nickname birthdate gender id firstname lastname phone best_call_time}.each do |f|
    self.send("#{f}=", json[f])
  end
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



46
47
48
# File 'lib/ae_users_migrator/import.rb', line 46

def 
  @account
end

#best_call_timeObject

Returns the value of attribute best_call_time.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def best_call_time
  @best_call_time
end

#birthdateObject

Returns the value of attribute birthdate.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def birthdate
  @birthdate
end

#email_addressesObject (readonly)

Returns the value of attribute email_addresses.



46
47
48
# File 'lib/ae_users_migrator/import.rb', line 46

def email_addresses
  @email_addresses
end

#firstnameObject

Returns the value of attribute firstname.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def firstname
  @firstname
end

#genderObject

Returns the value of attribute gender.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def gender
  @gender
end

#idObject

Returns the value of attribute id.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def id
  @id
end

#lastnameObject

Returns the value of attribute lastname.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def lastname
  @lastname
end

#nicknameObject

Returns the value of attribute nickname.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def nickname
  @nickname
end

#open_id_identitiesObject (readonly)

Returns the value of attribute open_id_identities.



46
47
48
# File 'lib/ae_users_migrator/import.rb', line 46

def open_id_identities
  @open_id_identities
end

#phoneObject

Returns the value of attribute phone.



47
48
49
# File 'lib/ae_users_migrator/import.rb', line 47

def phone
  @phone
end

#rolesObject (readonly)

Returns the value of attribute roles.



46
47
48
# File 'lib/ae_users_migrator/import.rb', line 46

def roles
  @roles
end

Instance Method Details

#primary_email_addressObject



72
73
74
# File 'lib/ae_users_migrator/import.rb', line 72

def primary_email_address
  @email_addresses.select { |ea| ea.primary }.first || @email_addresses.first
end