summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-03-18 15:49:11 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-03-18 15:49:11 +0000
commitb5d9a1dfbdbaf3b4193efb3bf3654a33670ff0d6 (patch)
tree7b886f83599b1a2f7e1c891e9982eb4715e12f38 /app/models
parentf741ca726978cfc352a0387f4694d7e29fb72803 (diff)
downloadredmine-b5d9a1dfbdbaf3b4193efb3bf3654a33670ff0d6.tar.gz
redmine-b5d9a1dfbdbaf3b4193efb3bf3654a33670ff0d6.zip
Refactor: Extract method to the Member model
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3601 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/member.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index 3ef1afdef..94751efb2 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -71,6 +71,13 @@ class Member < ActiveRecord::Base
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
end
end
+
+ # Find or initilize a Member with an id, attributes, and for a Principal
+ def self.edit_membership(id, new_attributes, principal=nil)
+ @membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
+ @membership.attributes = new_attributes
+ @membership
+ end
protected