Class: TheCity::User
Constant Summary collapse
- Gender =
{:male => 'Male', :female => 'Female'}
- PhoneType =
{:home => 'Home', :work => 'Work', :mobile => 'Mobile'}
- MaritalStatus =
{:never_married => 'Never Married', :engaged => 'Engaged', :married => 'Married', :separated => 'Separated', :divorced => 'Divorced', :remarried => 'Re-Married', :widowed => 'Widowed', :cohabiting => 'Cohabiting'}
Instance Attribute Summary
Attributes inherited from ApiObject
#error_messages, #marked_for_destruction
Class Method Summary collapse
-
.load_by_id(user_id, options = {}) ⇒ Object
Loads the user by the specified ID.
Instance Method Summary collapse
-
#admin_privileges(force_reload = false) ⇒ UserAdminPrivilegeList
The invitations for this user.
-
#family(force_reload = false) ⇒ UserFamilyList
The family information.
-
#first_name_with_nickname ⇒ Object
The first with the nickname in parens if available.
-
#full_name ⇒ Object
The first and last name of the user.
-
#initialize(json_data = nil, options = {}) ⇒ User
constructor
Constructor.
-
#invitations(force_reload = false) ⇒ UserInvitationList
The invitations for this user.
-
#notes(force_reload = false) ⇒ UserNoteList
The notes for this user.
-
#processes(force_reload = false) ⇒ UserProcessList
The processes for this user.
-
#roles(force_reload = false) ⇒ UserRoleList
The roles for this user.
-
#skills(force_reload = false) ⇒ UserSkillList
The skills for this user.
Methods inherited from ApiObject
__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes
Constructor Details
#initialize(json_data = nil, options = {}) ⇒ User
Constructor.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/api/user.rb', line 72 def initialize(json_data = nil, = {}) @writer_object = UserWriter initialize_from_json_object(json_data) unless json_data.nil? @addresses = @addresses.nil? ? [] : @addresses.collect { |addr| UserAddress.new(addr.merge({:user_id => self.id})) } @family_list = nil @note_list = nil @role_list = nil @skill_list = nil @process_list = nil @invitation_list = nil @admin_privilege_list = nil end |
Class Method Details
.load_by_id(user_id, options = {}) ⇒ Object
Loads the user by the specified ID.
Returns a new TheCity::User object.
60 61 62 63 64 65 |
# File 'lib/api/user.rb', line 60 def self.load_by_id(user_id, = {}) reader = UserReader.new(user_id, ) self.new(reader.load_feed, ) rescue nil end |
Instance Method Details
#admin_privileges(force_reload = false) ⇒ UserAdminPrivilegeList
The invitations for this user.
193 194 195 196 197 198 199 200 201 |
# File 'lib/api/user.rb', line 193 def admin_privileges(force_reload = false) unless force_reload return @admin_privilege_list unless @admin_privilege_list.nil? end return nil unless self.id @admin_privilege_list = UserAdminPrivilegeList.new({:user_id => self.id}) return @admin_privilege_list end |
#family(force_reload = false) ⇒ UserFamilyList
The family information.
109 110 111 112 113 114 115 116 117 |
# File 'lib/api/user.rb', line 109 def family(force_reload = false) unless force_reload return @family_list unless @user_list.nil? end return nil unless self.id @family_list = UserFamilyList.new({:user_id => self.id}) return @family_list end |
#first_name_with_nickname ⇒ Object
The first with the nickname in parens if available.
91 92 93 94 |
# File 'lib/api/user.rb', line 91 def first_name_with_nickname with_nickname = self.nickname.to_s.empty? ? nil : "(#{self.nickname})" [self.first, with_nickname].compact.join(' ') end |
#full_name ⇒ Object
The first and last name of the user.
100 101 102 103 |
# File 'lib/api/user.rb', line 100 def full_name use_name = self.nickname.to_s.empty? ? self.first : self.nickname [use_name, self.last].compact.join(' ') end |
#invitations(force_reload = false) ⇒ UserInvitationList
The invitations for this user.
179 180 181 182 183 184 185 186 187 |
# File 'lib/api/user.rb', line 179 def invitations(force_reload = false) unless force_reload return @invitation_list unless @invitation_list.nil? end return nil unless self.id @invitation_list = UserInvitationList.new({:user_id => self.id}) return @invitation_list end |
#notes(force_reload = false) ⇒ UserNoteList
The notes for this user.
123 124 125 126 127 128 129 130 131 |
# File 'lib/api/user.rb', line 123 def notes(force_reload = false) unless force_reload return @note_list unless @note_list.nil? end return nil unless self.id @note_list = UserNoteList.new({:user_id => self.id}) return @note_list end |
#processes(force_reload = false) ⇒ UserProcessList
The processes for this user.
165 166 167 168 169 170 171 172 173 |
# File 'lib/api/user.rb', line 165 def processes(force_reload = false) unless force_reload return @process_list unless @process_list.nil? end return nil unless self.id @process_list = UserProcessList.new({:user_id => self.id}) return @process_list end |
#roles(force_reload = false) ⇒ UserRoleList
The roles for this user.
137 138 139 140 141 142 143 144 145 |
# File 'lib/api/user.rb', line 137 def roles(force_reload = false) unless force_reload return @role_list unless @role_list.nil? end return nil unless self.id @role_list = UserRoleList.new({:user_id => self.id}) return @role_list end |
#skills(force_reload = false) ⇒ UserSkillList
The skills for this user.
151 152 153 154 155 156 157 158 159 |
# File 'lib/api/user.rb', line 151 def skills(force_reload = false) unless force_reload return @skill_list unless @skill_list.nil? end return nil unless self.id @skill_list = UserSkillList.new({:user_id => self.id}) return @skill_list end |