| Class | Person |
| In: |
app/models/person.rb
|
| Parent: | ActiveRecord::Base |
個人のモデル。
p と q が同一かどうかを判定する。
# File app/models/person.rb, line 41
41: def self.exists_with_people?(p, q)
42: return (p == q)
43: end
同じ組織に属する個人を配列で返す。
# File app/models/person.rb, line 66
66: def colleagues
67: organizations.inject([]) do |seed, organization|
68: seed | organization.people
69: end
70: end
所属する企業を配列で返す。
# File app/models/person.rb, line 46
46: def companies
47: company_members.map(&:company).flatten
48: end
所属するグループを配列で返す。
# File app/models/person.rb, line 61
61: def groups
62: group_members.map(&:group).flatten
63: end
名前および企業の名前と組織の名前を返す。
# File app/models/person.rb, line 80
80: def name_with_in
81: if company = preferred_company
82: if organization = preferred_organization
83: "#{name} (#{preferred_company.name}/#{preferred_organization.name})"
84: else
85: "#{name} (#{preferred_company.name})"
86: end
87: end
88: return name
89: end
同じグループに属する個人を配列で返す。
# File app/models/person.rb, line 73
73: def neighbors
74: groups.inject([]) do |seed, group|
75: seed | group.people
76: end
77: end
所属する組織を配列で返す。
# File app/models/person.rb, line 56
56: def organizations
57: organization_members.map(&:organization).flatten
58: end
役職を配列で返す。
# File app/models/person.rb, line 51
51: def posts
52: posted_tos.map(&:post).flatten
53: end
優先される所属企業を返す。
# File app/models/person.rb, line 92
92: def preferred_company
93: get_preferred("company")
94: end
優先される所属組織を返す。
# File app/models/person.rb, line 102
102: def preferred_organization
103: get_preferred("organization")
104: end