@@ -108,6 +108,11 class Principal < ActiveRecord::Base | |||
|
108 | 108 | |
|
109 | 109 | before_create :set_default_empty_values |
|
110 | 110 | |
|
111 | def reload(*args) | |
|
112 | @project_ids = nil | |
|
113 | super | |
|
114 | end | |
|
115 | ||
|
111 | 116 | def name(formatter = nil) |
|
112 | 117 | to_s |
|
113 | 118 | end |
@@ -124,9 +129,14 class Principal < ActiveRecord::Base | |||
|
124 | 129 | Principal.visible(user).where(:id => id).first == self |
|
125 | 130 | end |
|
126 | 131 | |
|
127 | # Return true if the principal is a member of project | |
|
132 | # Returns true if the principal is a member of project | |
|
128 | 133 | def member_of?(project) |
|
129 |
project |
|
|
134 | project.is_a?(Project) && project_ids.include?(project.id) | |
|
135 | end | |
|
136 | ||
|
137 | # Returns an array of the project ids that the principal is a member of | |
|
138 | def project_ids | |
|
139 | @project_ids ||= super.freeze | |
|
130 | 140 | end |
|
131 | 141 | |
|
132 | 142 | def <=>(principal) |
General Comments 0
You need to be logged in to leave comments.
Login now