module MnoEnterprise::Concerns::Models::Team

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

Public Instance Methods

add_user(user) click to toggle source
Instance methods
Add a user to the team
TODO: specs
# File lib/mno_enterprise/concerns/models/team.rb, line 47
def add_user(user)
  self.users.create(id: user.id)
end
remove_user(user) click to toggle source

Remove a user from the team TODO: specs

# 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) click to toggle source

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

# 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_event() click to toggle source
# File lib/mno_enterprise/concerns/models/team.rb, line 68
def to_audit_event
  {
    name: name,
    organization_id: self.organization.id
  }
end