Class: MnoEnterprise::Team

Inherits:
BaseResource show all
Defined in:
app/models/mno_enterprise/team.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#==, base_class, #cache_key, #clear_association_cache, #clear_attribute_changes!, find_by, first, last, #max_updated_column_timestamp, #read_attribute, #reload, #save, #save!, #update, #write_attribute

Methods included from HerExtension::Validations::RemoteUniquenessValidation

included

Instance Method Details

#add_user(user) ⇒ Object

Add a user to the team TODO: specs



29
30
31
# File 'app/models/mno_enterprise/team.rb', line 29

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

#remove_user(user) ⇒ Object

Remove a user from the team TODO: specs



35
36
37
# File 'app/models/mno_enterprise/team.rb', line 35

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



42
43
44
45
46
47
48
# File 'app/models/mno_enterprise/team.rb', line 42

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