Module: MnoEnterprise::Concerns::Models::Team

Extended by:
ActiveSupport::Concern
Included in:
Team
Defined in:
lib/mno_enterprise/concerns/models/team.rb

Overview

Schema Information

Endpoint:

- /v1/teams
- /v1/organizations/:organization_id/teams

id              :integer         not null, primary key
name            :string(255)
created_at      :datetime        not null
updated_at      :datetime        not null
organization_id :integer

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_user(user) ⇒ Object

Instance methods

Add a user to the team TODO: specs



47
48
49
# File 'lib/mno_enterprise/concerns/models/team.rb', line 47

def add_user(user)
  self.users.create(id: user.id)
end

#remove_user(user) ⇒ Object

Remove a user from the team TODO: specs



53
54
55
# File 'lib/mno_enterprise/concerns/models/team.rb', line 53

def remove_user(user)
  self.users.destroy(id: user.id)
end

#set_access_to(collection_or_array) ⇒ Object

Set the app_instance permissions of this team Accept a collection of hashes or an array of ids TODO: specs



60
61
62
63
64
65
66
# File 'lib/mno_enterprise/concerns/models/team.rb', line 60

def set_access_to(collection_or_array)
  # Empty arrays do not seem to be passed in the request. Force value in this case
  list = collection_or_array.empty? ? [""] : collection_or_array
  self.put(data: { set_access_to: list })
  self.reload
  self
end

#to_audit_eventObject



68
69
70
71
72
73
# File 'lib/mno_enterprise/concerns/models/team.rb', line 68

def to_audit_event
  {
    name: name,
    organization_id: self.organization.id
  }
end