Skip to content

Instantly share code, notes, and snippets.

@cored
Last active December 14, 2015 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cored/5033948 to your computer and use it in GitHub Desktop.
Save cored/5033948 to your computer and use it in GitHub Desktop.
module Domain¬
class CollaboratorRepository¬
def self.add(project, users)¬
users.each do |user|¬
user = User.find(user) if user.is_a?(BSON::ObjectId)¬
project.collaborator_ids << user.id unless !user.is_a?(User) or user.guest? or project.collaborator_ids.include?(user.id)¬
Sentry.init(project.id, user.id)¬
project.save
end¬
end¬
¬
def self.remove(project, users)¬
users.each do |user|¬
user = User.find(user) if user.is_a?(BSON::ObjectId)¬
project.collaborator_ids.delete(user.id) unless !user.is_a?(User) or user.guest? or !project.collaborators.include?(user)¬
Sentry.init(project.id, user.id).destroy¬
end¬
project.save¬
end¬
end¬
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment