Class: Linguist::Models::Collaborator

Inherits:
Object
  • Object
show all
Defined in:
lib/linguist_ruby/models/collaborator.rb

Constant Summary collapse

ROLES_NAMES =
{ "project_admin" => "Project admin", "developer" => "Developer" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, link) ⇒ Collaborator

Returns a new instance of Collaborator.



8
9
10
11
# File 'lib/linguist_ruby/models/collaborator.rb', line 8

def initialize(client, link)
  @client = client
  @link = link
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



4
5
6
# File 'lib/linguist_ruby/models/collaborator.rb', line 4

def display_name
  @display_name
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/linguist_ruby/models/collaborator.rb', line 4

def email
  @email
end

#rolesObject

Returns the value of attribute roles.



4
5
6
# File 'lib/linguist_ruby/models/collaborator.rb', line 4

def roles
  @roles
end

Instance Method Details

#destroyObject



13
14
15
# File 'lib/linguist_ruby/models/collaborator.rb', line 13

def destroy
  @client.delete @link
end

#permissionsObject



17
18
19
20
21
# File 'lib/linguist_ruby/models/collaborator.rb', line 17

def permissions
  return "None" if self.roles.nil? or self.roles.empty?

  self.roles.find_all { |role| ROLES_NAMES.has_key?(role) }.join(", ")
end