Class: User

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/user.rb

Constant Summary collapse

PERSON_ATTR =
%w(name fname lname minitial prefix suffix email phone emails phones addresses birthdate age nationality language)
PERSON_SYMS =
PERSON_ATTR.collect {|x| [x.to_sym, (x + "=").to_sym] }.flatten
PERSON_SET =
PERSON_SYMS + PERSON_ATTR

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lookup(item) ⇒ Object



12
13
14
15
16
# File 'app/models/user.rb', line 12

def self.lookup(item)
  person = Person.lookup(item)
  this_class = self.name.downcase.to_sym
  (person.send this_class) if person and person.respond_to?(this_class)
end

Instance Method Details

#assign_attributes(attr) ⇒ Object



26
27
28
29
# File 'app/models/user.rb', line 26

def assign_attributes(attr)
  self.person ||= Person.new if not attr.keys.to_set.intersection(PERSON_SET).empty?
  super(attr)
end

#organizationObject



22
23
24
# File 'app/models/user.rb', line 22

def organization
  self.organizations.order(created_at: :desc).first
end

#organization=(org) ⇒ Object



18
19
20
# File 'app/models/user.rb', line 18

def organization=(org)
  self.organizations << org if not self.organizations.include?(org)
end